This repository contains code that is able to recognize license-plate characters from images. This project contains the Segmentation
and Recognition
parts.
The Segmentation model was built using the UNet architecture because of its very good performance with few annotated images. The data used in training this model is the Tunisian vehicle license plates
(900 images) got from Zindi.
The Darknet framework was used for the Recognition.
Ubuntu -> 20.04 | Python -> 3.8 | OpenCV -> 4.7.0 | NumPy -> 1.21 | PyTorch -> 1.13.1 | Darknet
The Darknet framework is in a self-contained 'darknet' folder and needs to be compiled before being used. To compile this, run
$ cd darknet && make
After building the Darknet, one needs to download the necessary data and configuration files by running,
$ bash get-networks.sh
The 'run.sh' is used to execute the ALPR. The script requires 2 arguments:
- Input directory (-i): The input directory which should contain at least one image.
- Output directory (-o): The output directory into which generated data will be saved.
$ bash get-networks.sh && run.sh -i samples/test -o samples/output
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
You can choose to train the segmentation model from scratch or fine-tune using your own data. This data must live in a directory containing two sub-directories imgs
and masks
./data/*
|--- data/ocr - # Weights and configuration files for OCR
|--- data/train/* - # Train data
| |--- data/train/imgs - # Images for training ('jpg' or 'png')
| |--- data/train/masks - # Masks to images with same file name ('jpg' or 'png')
|--- Everything else - # Files for data processing
|--- data/unet - # Weights to U-Net model
Go on to use the following commands in training the network with your data
$ python3 train.py -p data/train -e 50 -bs 32 --weights data/unet/final_checkpoint
for fine-tuning, use the --weights
argument to specify the path to pre-trained weights.
- Zindi: Computer Vision for License Plate Recognition Challenge
- ALPR in Unconstrained Scenarios
- U-Net: Convolutional Networks for Biomedical Image Segmentation
- Darknet: Open Source Neural Networks in C