Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,155 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- 0xnu/uk-licence-plate
|
5 |
+
tags:
|
6 |
+
- uk
|
7 |
+
- united-kingdom
|
8 |
+
- transport
|
9 |
+
- transportation
|
10 |
+
- computer-vision
|
11 |
+
- object-detection
|
12 |
+
- license-plate-recognition
|
13 |
+
- ocr
|
14 |
+
language:
|
15 |
+
- en
|
16 |
+
---
|
17 |
+
|
18 |
+
## UKLPR: United Kingdom License Plate Recognition
|
19 |
+
|
20 |
+
UKLPR is a computer-vision model architecture purpose-built for detecting, reading, and recognizing United Kingdom license plates. It is optimized for speed and accuracy across diverse UK plate formats.
|
21 |
+
|
22 |
+
### Model Performance
|
23 |
+
|
24 |
+
- **Detection Rate**: 100.0%
|
25 |
+
- **Text Extraction Rate**: 100.0%
|
26 |
+
- **Processing Speed**: 8.1 FPS
|
27 |
+
- **Model Size**: YOLOv8 Nano (~12.3MB)
|
28 |
+
|
29 |
+
### Supported Languages
|
30 |
+
|
31 |
+
- English (en)
|
32 |
+
|
33 |
+
### Quick Start
|
34 |
+
|
35 |
+
#### Installation
|
36 |
+
|
37 |
+
```python
|
38 |
+
pip install ultralytics easyocr opencv-python pillow torch torchvision huggingface_hub
|
39 |
+
```
|
40 |
+
|
41 |
+
#### Usage
|
42 |
+
|
43 |
+
```python
|
44 |
+
import cv2
|
45 |
+
import numpy as np
|
46 |
+
from ultralytics import YOLO
|
47 |
+
import easyocr
|
48 |
+
from PIL import Image
|
49 |
+
from huggingface_hub import hf_hub_download
|
50 |
+
import warnings
|
51 |
+
|
52 |
+
# Suppress warnings
|
53 |
+
warnings.filterwarnings('ignore')
|
54 |
+
|
55 |
+
# Download models from HuggingFace
|
56 |
+
print("Downloading model from HuggingFace...")
|
57 |
+
model_path = hf_hub_download(repo_id="0xnu/uk-license-plate-recognition", filename="model.onnx")
|
58 |
+
config_path = hf_hub_download(repo_id="0xnu/uk-license-plate-recognition", filename="config.json")
|
59 |
+
|
60 |
+
# Load models with explicit task specification
|
61 |
+
yolo_model = YOLO(model_path, task='detect')
|
62 |
+
ocr_reader = easyocr.Reader(['en'], gpu=False, verbose=False)
|
63 |
+
|
64 |
+
# Process image
|
65 |
+
def recognize_license_plate(image_path):
|
66 |
+
# Load image
|
67 |
+
image = cv2.imread(image_path)
|
68 |
+
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
69 |
+
|
70 |
+
# Detect license plates
|
71 |
+
results = yolo_model(image_rgb, conf=0.5, verbose=False)
|
72 |
+
|
73 |
+
plates = []
|
74 |
+
for result in results:
|
75 |
+
boxes = result.boxes
|
76 |
+
if boxes is not None:
|
77 |
+
for box in boxes:
|
78 |
+
# Get coordinates
|
79 |
+
x1, y1, x2, y2 = box.xyxy[0].cpu().numpy()
|
80 |
+
|
81 |
+
# Crop plate
|
82 |
+
plate_crop = image_rgb[int(y1):int(y2), int(x1):int(x2)]
|
83 |
+
|
84 |
+
# Extract text
|
85 |
+
ocr_results = ocr_reader.readtext(plate_crop)
|
86 |
+
if ocr_results:
|
87 |
+
text = ocr_results[0][1]
|
88 |
+
confidence = float(ocr_results[0][2]) # Convert to native Python float
|
89 |
+
plates.append({'text': text, 'confidence': confidence})
|
90 |
+
|
91 |
+
return plates
|
92 |
+
|
93 |
+
# Usage Example
|
94 |
+
results = recognize_license_plate('sample_car_with_license.jpeg')
|
95 |
+
print(results)
|
96 |
+
```
|
97 |
+
|
98 |
+
### Model Architecture
|
99 |
+
|
100 |
+
#### Detection Model (YOLOv8n)
|
101 |
+
- **Architecture**: YOLOv8 Nano
|
102 |
+
- **Parameters**: ~3M
|
103 |
+
- **Input Size**: 640x640 pixels
|
104 |
+
- **Output**: Bounding boxes for license plates
|
105 |
+
|
106 |
+
#### OCR Model (EasyOCR)
|
107 |
+
- **Engine**: Deep learning-based OCR
|
108 |
+
- **Languages**: English
|
109 |
+
- **Character Set**: Alphanumeric + common symbols
|
110 |
+
|
111 |
+
### Training Details
|
112 |
+
|
113 |
+
- **Dataset**: UK License Plate Dataset ([0xnu/uk-licence-plate](https://huggingface.co/datasets/0xnu/uk-licence-plate))
|
114 |
+
- **Training Epochs**: 10
|
115 |
+
- **Batch Size**: 16
|
116 |
+
- **Image Size**: 640x640
|
117 |
+
- **Optimizer**: AdamW
|
118 |
+
- **Framework**: Ultralytics YOLOv8
|
119 |
+
|
120 |
+
### Use Cases
|
121 |
+
|
122 |
+
- Traffic monitoring systems
|
123 |
+
- Automated parking management
|
124 |
+
- Law enforcement applications
|
125 |
+
- Toll collection systems
|
126 |
+
- Vehicle access control
|
127 |
+
|
128 |
+
### Limitations
|
129 |
+
|
130 |
+
- Optimized for United Kingdom license plate formats
|
131 |
+
- Performance may vary with extreme weather conditions
|
132 |
+
- Requires good image quality for optimal text recognition
|
133 |
+
- Real-time performance depends on hardware capabilities
|
134 |
+
|
135 |
+
### License
|
136 |
+
|
137 |
+
This project is licensed under the [Modified MIT License](./LICENSE).
|
138 |
+
|
139 |
+
### Citation
|
140 |
+
|
141 |
+
If you use this model in your research or product, please cite:
|
142 |
+
|
143 |
+
```bibtex
|
144 |
+
@misc{uklpr2025,
|
145 |
+
title={UKLPR: United Kingdom License Plate Recognition},
|
146 |
+
author={Finbarrs Oketunji},
|
147 |
+
year={2025},
|
148 |
+
publisher={Hugging Face},
|
149 |
+
howpublished={\url{https://huggingface.co/0xnu/uk-license-plate-recognition}}
|
150 |
+
}
|
151 |
+
```
|
152 |
+
|
153 |
+
### Copyright
|
154 |
+
|
155 |
+
Copyright (C) 2025 Finbarrs Oketunji. All Rights Reserved.
|