Skip to content

Iraninan car license plate recognition using implementation of YOLOv7 (Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors)

License

Notifications You must be signed in to change notification settings

fatemenajafi135/persian-anpr

 
 

Repository files navigation

Automatic Number Plate Recognizition for Iranian(Persian) plates

License plate detection

Install requirements

pip install -r requirements.txt (--use-feature=2020-resolver)

dataset

I used two datasets (car plate dataset and Iranian car number plate) for transfer learning the YOLOv7 to detect car license plates. As I wantet better performance on Iranian license plates, during spliting the whole dataset, I set splits ratio for train/validation/test of the Iranian dataset to 70/15/15 and the other dataset to 75/25/0. I used flip horizontal, rotation (-10° to +10°), shear (±10° to ±10°), and noise(5%) for augmentation.

Add the new dataset from roboflow for training or fune-tuning using your specific API key. The car license plate dataset will be placed at ./ANPR_Iran-car-1.

run download_dataset.py --api [YOUR SPECIFIC API KEY]

download the base model weights of YOLOv7

wget -P ./weights https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt

transfer learning for license plate detection

train model:

python train.py --epochs 50 --workers 8 --device 0 --batch-size 16 --data ANPR_Iran-car-1/data.yaml --img 640 640 --cfg cfg/training/yolov7.yaml --weights 'yolov7.pt' --name yolov7-license --hyp data/hyp.scratch.custom.yaml

or download the best model I have trained for car lisense plate detection:

cd weights
gdown 1fsf3T_u3wvPJQJDTMi8LfVdCxIUUA34S
cd ..

detect license plates for the testset using model: ‍‍‍‍‍‍

python detect.py --weights [PATH TO WEIGHTS (.pt file)] --conf 0.1 --source [PATH TO A DIRECTORY OR A SINGLE IMAGE TO DETECT]
# example using my model 
python detect.py --weights weights/best.pt --conf 0.2 --source ./ANPR_Iran-car-1/test/images

Results will be placed on runs/detect/exp*.

ocr

More on OCR ...

Wrap up for license plate recognition

using easyocr

change [...] in line 78 on file utils/plots.py to the direct path of Yekan.ttf on your system.

python anpr.py --path2detect [PATH OF FILES] --detecttype [FILE TYPE] --imagename [IMAGE NAME] --videoname [VIDEO NAME] --weights weights/best.pt --savepath runs/recognize  --device cpu --imagesize 640
#Example
python anpr.py --path2detect ./to_detect --detecttype image --imagename plate.jpg

YOLOv7

More about YOLO7

About

Iraninan car license plate recognition using implementation of YOLOv7 (Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 98.7%
  • Python 1.3%