UK licence plate recognition with YOLOv8 and OpenCV.
A YOLOv8n model, fine-tuned on 10k annotated plate images, finds licence plates in a photo and returns a padded crop of each one, sorted by confidence. On the dataset's unseen test split it scores precision 0.986, recall 0.945 and mAP50 0.975. A holdout script measures detection recall on real, hand-labelled UK photos, broken down by conditions such as angled, blurry or far away.
uv venv --python 3.11 .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# NVIDIA GPU (CUDA 12.8, required for RTX 50-series); skip for CPU-only
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
uv pip install -r requirements.txt
pytest| Path | Contents |
|---|---|
src/detection |
YOLO plate detection |
src/ocr |
Crop preprocessing, OCR, UK format validation |
src/pipeline |
End-to-end orchestration |
data/holdout |
Real photos + ground_truth.csv (both git-ignored for privacy; format in ground_truth.example.csv), never trained on |
scripts |
Evaluation and data-prep entry points |
- Detection: Roboflow License Plate Recognition (10k annotated images)
- OCR fine-tune: UK synthetic plates (48k, DVLA spacing)
- Evaluation: self-collected holdout, hand-labelled
Note: AI assistance was used to help write the tests.