VehicleGenome

Roadside vehicle intelligence: plate OCR + vehicle fingerprinting on commodity hardware. A Flock-Safety-style capability (fixed camera → plate + vehicle attributes → searchable sighting record → re-identification), built as a working prototype, an evaluation harness, a feasibility study and a conference-paper draft.

/root/VehicleGenome
├── app/main.py            FastAPI service (API + operator UI)
├── core/
│   ├── alpr_engine.py     YOLOv9-t plate detector + CCT-xs OCR (ONNX)
│   ├── clip_encoder.py    CLIP ViT-B/32 image/text embeddings (ONNX, quantised)
│   ├── fingerprint.py     vehicle crop, HSV colour descriptor, VLM attributes
│   ├── store.py           SQLite sighting store, cosine + Levenshtein search
│   └── pipeline.py        analyse(): image bytes → one JSON sighting
├── web/                   landing page, demo console, metrics page
├── eval/run_eval.py       evaluation harness → reports/metrics.json
├── data/                  datasets + sightings.db
├── models/                ONNX weights (CLIP)
├── docs/                  literature review, feasibility & business model
├── paper/                 LaTeX conference draft
└── reports/               metrics.json, eval logs

Run it

cd /root/VehicleGenome
set -a && . /root/.hermes/.env && set +a          # OPENROUTER_API_KEY (optional, for VLM attributes)
.venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8090

Pipeline

stage model runtime output
vehicle detection YOLOv5n COCO (fp16 ONNX) onnxruntime CPU one box per car/bus/truck/motorcycle
plate detection YOLOv9-t 384 (end-to-end) onnxruntime CPU box + confidence
plate OCR CCT-xs v2 global onnxruntime CPU text, per-char confidence, region
fingerprint CLIP ViT-B/32 (quantised) onnxruntime CPU 512-d embedding
colour HSV descriptor over vehicle crop numpy dominant colour + palette
attributes Qwen2.5-VL 72B (OpenRouter) network, optional make, model, body, colour, marks

Each detected vehicle gets its own record: its own crop, embedding, colour, attributes and the plate that falls inside its box. A vehicle with no readable plate still produces a record and stays retrievable by appearance or by description.

Everything except the attribute call runs locally with no network and no GPU.

API

POST   /api/analyze        multipart: file, vlm=true|false, camera=cam-01  → sighting JSON
POST   /api/search/image   multipart: file                                  → cosine neighbours
GET    /api/search/plate?q=ABC123&max_dist=2                                → fuzzy plate hits
POST   /api/analyze/video (file, sample_fps, camera)                       → tracks + unique plates
GET    /api/search/describe?q=gray+plate,broken+bumper&k=8                   → attribute/text search
GET    /api/trail?plate=ABC123                                              → cross-camera journey
GET    /api/watchlist · POST /api/watchlist · DELETE /api/watchlist/{plate}  → hotlist
GET    /api/alerts · POST /api/alerts/{id}/ack                              → alert queue
GET    /api/audit                                                           → query log
POST   /api/retention/purge?days=30                                         → delete old records
GET    /api/facets                                                          → common tags for chips
GET    /api/sightings?limit=24&plate=…                                      → recent gallery
GET    /api/stats          aggregate counts
GET    /api/metrics        reports/metrics.json
DELETE /api/reset          clear the gallery

Evaluation

.venv/bin/python eval/run_eval.py           # full (~10 min on 4 vCPU)
.venv/bin/python eval/run_eval.py --quick   # smoke run

Protocols and honest caveats are in reports/metrics.json under notes, and on /metrics.

Status (prototype)

Working: video ingest + tracking, hotlist alerts, audit log, retention purge, make/model head (linear probe, 0.779 vs 0.555 for the VLM on Stanford Cars), multi-vehicle decomposition, detection, OCR, fingerprint, colour, VLM attributes (damage / accessories / stickers / plate condition), gallery, cosine re-ID, fuzzy plate search, plate-free description search, live UI, evaluation harness.

Not done: Arabic/GCC plate data (the OCR model is a global Latin-script model — Saudi plates need a fine-tuned head), night/IR imagery, multi-camera track stitching, watchlists/alerts, and any production hardening (auth, retention policy, rate limits).

Licensing of third-party data

Paper

paper/main_conf6.tex — conference submission (IEEEtran conference, 6 pages, double-blind: no author block, no acknowledgments). paper/main.tex — the long version with the author block and full results.

cd paper && pdflatex main_conf6 && bibtex main_conf6 && pdflatex main_conf6 && pdflatex main_conf6

Target venue: 24th International IEEE Learning and Technology Conference (L&T 2027), Effat University, Jeddah, 27–28 January 2027. Full paper limit is 6 pages and review is double-blind, so the submission PDF carries no identifying information. The named author block is preserved in git history (git show 875d622:paper/main_conf6.tex) for the camera-ready version.

Every number in the paper is regenerated from reports/*.json; scripts/audit_paper_numbers.py checks that each headline value appears in both PDFs and that no retracted value survives. Run it after any rebuild.

Weights and data (not in this repository)

Model weights and datasets are large and separately licensed, so they are gitignored: