yolov5-license-plate-detection

YOLOv5 License Plate Detection (ONNX Runtime Inference)

Downloads GitHub Repository

Link: https://www.pexels.com/video/traffic-flow-in-the-highway-2103099/

This repository contains code and instructions for performing object detection using YOLOv5 inference with ONNX Runtime.

Features

Installation

Clone the Repository

git clone https://github.com/yourusername/yolov5-license-plate-detection.git
cd yolov5-license-plate-detection

Install Required Packages

pip install -r requirements.txt

Usage

Before running inference, you need to download weights of the YOLOv5 model weights in ONNX format.

Download weights (Linux)

sh download.sh anpr_yolov5s
               anpr_yolov5m

Note: The weights are saved in FP32.

Model Name ONNX Model Link Number of Parameters Model Size
YOLOv5s yolov5s.onnx 7.2M 28 MB
YOLOv5m yolov5m.onnx 21.2M 84 MB


If you have custom weights, you can convert your weights to ONNX format. Follow the instructions in the YOLOv5 repository to convert your model. You can use the converted ONNX model with this repository.

Inference

python main.py --weights weights/yolov5s.onnx --source assets/vid_input.mp4 # video
                                              --source 0 --view-img # webcam and display
                                              --source assets/img_input.jpg # image

Command Line Arguments

usage: main.py [-h] [--weights WEIGHTS] [--source SOURCE] [--img-size IMG_SIZE [IMG_SIZE ...]] [--conf-thres CONF_THRES] [--iou-thres IOU_THRES]
               [--max-det MAX_DET] [--save-img] [--view-img] [--project PROJECT] [--name NAME]

options:
  -h, --help            show this help message and exit
  --weights WEIGHTS     model path
  --source SOURCE       Path to video/image/webcam
  --img-size IMG_SIZE [IMG_SIZE ...]
                        inference size h,w
  --conf-thres CONF_THRES
                        confidence threshold
  --iou-thres IOU_THRES
                        NMS IoU threshold
  --max-det MAX_DET     maximum detections per image
  --save-img            Save detected images
  --view-img            View inferenced images
  --project PROJECT     save results to project/name
  --name NAME           save results to project/name

Reference

  1. https://github.com/ultralytics/yolov5