Skip to content

Dodant/anpr-with-yolo-v4

Repository files navigation

ALPR-with-Yolo-v4

ALPR with YOLOv4 is an advanced Automatic License Plate Recognition (ALPR) system that leverages the powerful YOLOv4 (You Only Look Once) one-stage object detection framework. It can efficiently and accurately detect and recognize vehicle license plates in real-time.

About Darknet : http://pjreddie.com/darknet/

Download Model

Classes

  • car
  • license_plate

Training

Labeling Tool : https://github.com/AlexeyAB/Yolo_mark

Darknet (Yolov4) : https://github.com/AlexeyAB/darknet

Cloud Service GPU Traing Data Training Iterations Time
GCP(Google Cloud Platform) Nvidia Tesla P100 Over 2600 images 4000 iterations 5h

./darknet detector train data/obj.data cfg/yolov4_ANPR.cfg yolov4.conv.137 -gpu 0

Usage (test)

  1. git clone https://github.com/AlexeyAB/darknet
  2. cd darknet
  3. Configure Makefile according to your environment: vi Makefile
GPU=0        # Change to 1 if using GPU
CUDNN=0      # Change to 1 if using cuDNN (NVIDIA)
CUDNN_HALF=0
OPENCV=0     # Change to 1 if using OpenCV
AVX=0
OPENMP=0
LIBSO=1      # Generate libdarknet.so

...
...
  1. make
  • Required packages: make, gcc, pkg-config (if not installed, use sudo apt-get install … to install)
  1. Download data/*, cfg/yolov4-ANPR.cfg, and backup/yolov4-ANPR.weights

image

./darknet detector test data/obj.data cfg/yolov4-ANPR.cfg backup/yolov4-ANPR.weights data/(이미지파일.jpg)

Make sure to use .jpg images

video

./darknet detector demo data/obj.data cfg/yolov4-ANPR.cfg backup/yolov4-ANPR.weights data/(동영상파일.mp4)

webcam

./darknet detector demo data/obj.data cfg/yolov4-ANPR.cfg backup/yolov4-ANPR.weights

Example

Prediction Image

./darknet detector test data/obj.data cfg/yolov4-ANPR.cfg backup/yolov4-ANPR.weights data/testfile.jpg

Loading weights from backup/yolov4-ANPR.weights...
 seen 64, trained: 256 K-images (4 Kilo-batches_64)
Done! Loaded 162 layers from weights-file
data/testfile.jpg: Predicted in 9325.005000 milli-seconds.
car: 63%
car: 98%
license_plate: 96%
car: 47%
car: 61%
car: 30%

predictions

Prediction Video

  • ./darknet detector demo data/obj.data cfg/yolov4-ANPR.cfg backup/yolov4-ANPR.weights data/testvideo.jpg
  • python darknet_video.py

Demo Video Link (1) : https://drive.google.com/file/d/1DGmF2bwtDMe1y-wNuv_YT827Vr6Y8Q2m/view?usp=sharing

Demo Video Link (2) : https://drive.google.com/file/d/1nJjIQFcrYRYSJ0n9FK0-x_Fk6HrULsZY/view?usp=sharing

References

Presentation