The ANPR system detects and recognizes vehicle license plates from images or video streams. Built for Indian license plates, it handles diverse plate formats, various lighting conditions, and challenging scenarios.
Tech Stack:
- Detection: YOLOv11 (fine-tuned for license plates)
- OCR: RapidOCR (ONNX runtime, ~50-100ms per plate)
- API: FastAPI REST endpoints
- Frontend: Alpine.js + Tailwind CSS
- Database: SQLite
- Python 3.10+
- NVIDIA GPU with CUDA 12.1 (recommended)
- 8GB RAM minimum
# 1. Create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Linux/Mac
# 2. Install dependencies
pip install -r requirements.txt
# 3. Download YOLOv11 license plate model
python scripts/download_plate_model.py --variant s
# 4. Start the server
python src/main.py --mode apiThe web UI is available at http://localhost:8000
- Open http://localhost:8000
- Upload a video or image
- View detected plates in Results
# Health check
curl http://localhost:8000/api/v1/health
# Process image
curl -X POST http://localhost:8000/api/v1/image/process \
-F "image=@plate.jpg"
# Upload video
curl -X POST http://localhost:8000/api/v1/upload \
-F "file=@video.mp4"
# Get detections
curl http://localhost:8000/api/v1/detections
# API documentation
open http://localhost:8000/api/v1/docspython src/main.py --mode cliCopy config.template.yaml to config.yaml to customize:
models:
yolo_model: yolov11s # n/s/m/l/x variants
yolo_weights: models/yolov11s-license-plate.pt
yolo_confidence: 0.4
yolo_fp16: true # GPU acceleration
api:
host: localhost
port: 8000Environment variables override config file:
ANPR_API_PORT- API portANPR_MODELS_YOLO_CONFIDENCE- Detection thresholdANPR_MODELS_YOLO_FP16- Enable/disable FP16
ANPR/
├── src/anpr/
│ ├── api/ # FastAPI endpoints
│ ├── cli/ # CLI interface
│ ├── core/ # Detection, OCR, video processing
│ ├── database/ # SQLite models and queries
│ └── config/ # Configuration management
├── static/ # Frontend (Alpine.js + Tailwind)
├── models/ # YOLO weights
├── data/ # Uploads, snapshots, database
└── scripts/ # Utilities
# Run tests
python test_integration.py
# Check CUDA availability
python scripts/check_cuda.py
# Demo pipeline on sample images
python scripts/demo_pipeline.pyOn NVIDIA RTX 4050 (6GB):
- YOLOv11s inference: ~10ms per frame
- OCR extraction: ~50-100ms per plate
- Full pipeline: ~100-150ms per frame
- FPS: ~90-100 (detection only)
CUDA not detected:
python -c "import torch; print(torch.cuda.is_available())"Model not found:
python scripts/download_plate_model.py --variant sMemory issues:
- Reduce
yolo_input_sizeto 416 - Disable
yolo_fp16if GPU memory is limited