This project implements a custom vehicle license plate detector using a YOLO (You Only Look Once) object detection model. It is capable of detecting license plates in images, videos, and live webcam feeds. Additionally, Optical Character Recognition (OCR) is applied to extract the plate numbers from detected plates.
- Download the dataset from Roboflow.
- Organize the dataset in the required structure in a directory titled
data
. - Create a
config.yaml
file specifying the paths to the training data in thedata
directory. - Train the model for 100 epochs using the
train.py
script. Transfer learning is utilized by starting with a pretrained YOLO model.
- To run object detection on an image, use
detect_on_img(img_path)
. - To perform detection on a video, use
detect_on_video(video_path)
. - For live detection on a webcam feed, use
detect_on_webcam()
.
The main()
function in predict.py
serves as the entry point for the application. It specifies paths for input images and videos, and calls the necessary functions for object detection.
data/
: Directory for storing the formatted training dataset.images/
: Original images for testing the detector.videos/
: Original videos for testing the detector.runs/
: Directory where trained models are stored.detect/
: Subdirectory for detection-related files.train/
: Trained model weights are stored here (best.pt
).
license_detections_webcam/
: Detected license plates from the webcam feed.license_detections_image/
: Detected license plates from images.license_detections_video/
: Detected license plates from videos.
This model employs transfer learning by utilizing a pretrained YOLO model. This approach allows the model to leverage knowledge gained from training on a large dataset for a similar task, significantly reducing the time and data required to achieve good performance on the license plate detection task.
- Ultralytics
- OpenCV
- EasyOCR
- NumPy
- Source of
filter_text
andsave_results
functions: RealTimeAutomaticNumberPlateRecognition
Jacob Pitsenberger