Home

Awesome

Objective

To train a model which will detect vehicle(Motorcycle, Auto-rikshaw, Bus, Car, Truck) present in frame along with its license plate

Solution Approach

The YOLO implementations are amazing tools that can be used to start detecting common objects in images and videos. However there are many cases,when the object which we want to detect are not part of the popular dataset. In such cases we need to create our own training set and execute our own training. Vehicle and its License plate detection are one such cases. I have used tiny-yolov3 to detect the desired classes and have collected around 1700+ images for training and validation.

Dataset

I have collected the image of vehicle of desired class from Google Image,Kaggle and by clicking some picture of vehicle from the roads so that the license plate of vehicle is visible. I have collected around 1700+ images and manually annotated all the desired classes in image. Each class consist of atleast 350 images in training dataset. Later converted the cooridnate of annotated object in yolo format that is:

<object-class> <x_center> <y_center> <width> <height>

Where:

VehicleLabel Id
Car0
Truck1
Bus2
Motorcycle3
Auto4
CarLP5
TruckLP6
BusLP7
MotorcycleLP8
AutoLP9
*License Plate(LP)

Later splitted all the dataset in training and validation set and stored the path of all the images in file named train.txt and valid.txt

Configuring Files

Yolov3 needs certain specific files to know how and what to train.

  1. obj.data
  2. obj.names
  3. obj.cfg

obj.data

This basically says that we are training 10 classes, what the train and validation files are and which file contains the name of object we want to detect.During training save the weight in backup folder.

classes = 10
train = train.txt
valid = test.txt
names = obj.names
backup = backup

obj.names

Every new cateogry must be in new line and its category number be same what we have used at the time of annotating data.

Car
Truck
Bus
Motorcycle
Auto
CarLP
TruckLP
BusLP
MotorcycleLP
AutoLP

obj.cfg

Just copied the tiny-yolov3.cfg files and made few changes in it.

then,save the file

Training

I have trained tiny-yolov3 for about 40,000 iterations and get the minimum total loss 0.15 with 0.001 learning rate, 0.9 Momentum and 0.0005 decay.

Training Loss Plot:

Loss Plot

Testing

For testing open the terminal and clone the repository by command

git clone https://github.com/SumanSudhir/Vehicle-and-Its-License-Plate-detection.git
cd Vehicle-and-Its-License-Plate-detection
make

Download weights from the link http://storage.googleapis.com/sudhir_storage/Yolov3/obj_60000.weights in Vehicle-and-Its-License-Plate-detection directory. Move one of your images in the testing group to the directory of Darknet and rename it as test.jpg Next, open Terminal in Vehicle-and-Its-License-Plate-detection directory and run

./darknet detector test obj.data cfg/obj.cfg obj_60000.weights test.jpg

In terminal you will see the class of object detected and resulting image will be stored in Vehicle-and-Its-License-Plate-detection directory with name prediction.jpg

Some Results

======= Truck Bike Car Bus Auto

References