Vehicle Edge Intelligence Logger - advanced AI for vehicular security and monitoring.
Download a license-plate YOLO checkpoint (for example keremberke/yolov8n-license-plate) and place it at models/yolov8n-license-plate.pt, or set the PLATE_MODEL_PATH environment variable to your custom .pt file before running main.py or main_video.py.
You can fine-tune a YOLO detector on the Indian license plates with labels dataset directly from this repo:
-
Prepare the splits
C:/btech/development/VEIL-AI/veilenv/Scripts/python.exe scripts/prepare_indian_lp_dataset.py
The script downloads the dataset via
kagglehub, creates deterministictrain/val/testsplits underdata/indian_lp/, mirrors the original download todata/indian_lp/raw/, and writes both a YOLOdata.yamland asummary.jsonwith useful counts. -
Train with Ultralytics YOLO
# Option A: call Ultralytics directly yolo detect train model=yolov8n.pt data=data/indian_lp/data.yaml epochs=80 imgsz=640 # Option B: use the helper wrapper (adds AdamW + cosine LR + patience) C:/btech/development/VEIL-AI/veilenv/Scripts/python.exe scripts/train_indian_lp.py \ --model yolov8n.pt \ --epochs 80 \ --imgsz 640
Replace
yolov8n.ptwith any starting checkpoint. Final weights will be emitted underruns/detect/.../weights/best.pt. -
Validate + wire into VEIL
# Quick validation report on the held-out test split yolo detect val model=runs/detect/<run-name>/weights/best.pt data=data/indian_lp/data.yaml split=test # or use the helper if PowerShell quoting is painful C:/btech/development/VEIL-AI/veilenv/Scripts/python.exe scripts/val_indian_lp.py \ --model runs/detect/<run-name>/weights/best.pt \ --split test --imgsz 640 --batch 16 # Update VEIL to use the refined detector copy runs/detect/<run-name>/weights/best.pt models/yolov8n-license-plate.pt # or set PLATE_MODEL_PATH directly in config.py / env vars
The latest YOLOv8n fine-tune (test split with 202 images) yields precision 0.995, recall 0.990, mAP50 0.995, and mAP50-95 0.865, confirming the new checkpoint surpasses the base detector.
Afterwards rerun
python main_video.py(or the live camera pipeline) and compare plate detection accuracy + speed.
To measure end-to-end accuracy on any folder of plate images:
python scripts/eval_plate_dataset.py \
--images path/to/plate/images \
--labels path/to/labels.csv \
--output reports/plate_eval.csvThe label file can be a CSV (image,plate columns) or JSON with the same keys. Add --fallback-stem if filenames already encode the ground truth text. The script reports detection hit rate, OCR exact-match rate, average similarity, and optionally writes a per-image CSV so you can inspect failures quickly.
- Default (Windows accuracy): EasyOCR (PyTorch-based) remains the most reliable reader out of the box. Keep
OCR_ENGINE=easyocr(default) for best results while you iterate on tuning. - Optional lightweight mode: set
OCR_ENGINE=tesseractif you installpytesseractplus the Tesseract binary (winget install tesseract-ocr.tesseracton Windows orsudo apt install tesseract-ocron Debian/Raspbian). Useful when you need a Pi-friendly footprint. - Additional knobs for Tesseract:
TESSERACT_CMD=C:/Program Files/Tesseract-OCR/tesseract.exe,TESSERACT_LANG,TESSERACT_PSM,TESSERACT_OEM. - Regardless of the engine, regex-enforced post-processing only accepts valid Indian plate formats, so uncertain reads are dropped rather than logged as hallucinations.
By default the pipeline attempts to sync completed entries to Firebase Cloud Firestore. Provide credentials in one of two ways:
- File path – download your Firebase service-account JSON and set
FIREBASE_CREDENTIALSto its absolute path (defaults toserviceAccount.jsonin the project root). - Inline JSON – set
FIREBASE_CREDENTIALS_JSONto the raw JSON string (useful for CI or secrets managers). The app writes it to.cache/firebase_credentials.jsonautomatically.
If you prefer a REST endpoint instead of Firebase, set CLOUD_PROVIDER=rest, point CLOUD_ENDPOINT to your API, and set CLOUD_API_KEY to the corresponding bearer token. Use --no-cloud on main.py / main_video.py for fully offline runs.