LAPI Tunisie: Tunisian license plate reader (CRNN)
A small CRNN (CNN + BiLSTM + CTC, 2.2 M parameters, 8.8 MB) trained from scratch to read
Tunisian license plates such as 106 تونس 5690. The Arabic word تونس is read as the letter T,
so the output is 106T5690.
It is step 5 of the LAPI Tunisie pipeline, after the plate detector.
Results
| Test | Exact match | CER |
|---|---|---|
| 94 validation plate crops | 94.7 % | 0.009 |
| 50 hand-labelled photos, full pipeline | 88 % | 0.025 |
On the same 50 photos: EasyOCR 50 %, Azure AI Vision 84 %.
Input and output
- Input: one plate crop, grey, resized to 32 × 128, values scaled to [-1, 1].
- Output: 31 columns × 12 classes (blank,
0–9,T), decoded greedily (merge repeats, drop blanks).
Usage
from huggingface_hub import hf_hub_download
import cv2
from crnn import load_crnn, read_plate # crnn.py from this repository
model = load_crnn(hf_hub_download("Chakster/lapi-tunisie-crnn", "crnn.pth"))
plate = cv2.imread("plate_crop.jpg")
print(read_plate(model, plate)) # ('106T5690', 0.99)
crnn.py holds the network definition, the preprocessing and the CTC decoding; it only needs
torch, numpy and opencv-python.
Training
- 900 plate crops with their text from Zindi AI Hack Tunisia 2 (792 for training, 94 for validation; two-line plates removed).
- Augmentation after epoch 10: margin, rotation ±5°, perspective, brightness, blur, noise.
- Up to 200 epochs, early stopping after 30; best epoch: 91.
Limits
Reads one line of text only (no two-line plates), and only the digits تونس digits format.
Plates tilted by more than about 10° are often misread by one digit.
Authors
Mohamed Ali Djemal, Ahmed Chakcha, Faculté des Sciences de Sfax.