Traffic Sign Object Detection With YOLOv5 Convolutional Neural Networks.
In this project, with using yolov5 algorithm and neural network, we collect, labeled, classified and trained 17 classes of traffic sign which can be detected with our final model.
All traffic signs can be detect by their position on the picture or video which can be previewed by a square around its shape.
A simple detection is like the picture below:
Using the collection of photos of traffic signs, which reached about 13 thousand photos, and that is the precondition of the project was read (collecting 10 to 15 classes of panels), so that from all the panels collected, 17 classes of panels should be considered for labeling.
The signs were selected based on 2 criteria from all the traffic signs in the dataset, which are:
- The prevalence of selected boards among all boards and simplifying their collection and normalization.
- The appearance and intuitive similarity of the collected panels to the panels used in Iran.
- The boards are placed in different places of the image.
The names and pictures of these 17 board classes are as follows:
After finishing the labeling process, 2006 photos were filtered. In filtering them, the following things were taken into account:
- Photos with useless data were removed from the collection.
- Photos with illegible data were removed from the collection.
- Low quality photos were removed from the collection.
- Photos that had other types similar to the above panels and caused problems for the project from the collection were deleted
The number of labeled photos for each class is listed in the following table:
# | Class Name | Number of labeled pictures |
---|---|---|
1 | one_way_traffic | 110 |
2 | parking_lot | 187 |
3 | pedestrian | 306 |
4 | give_way | 293 |
5 | no_waiting | 209 |
6 | speed_limit_30 | 139 |
7 | speed_limit_40 | 186 |
8 | speed_limit_50 | 157 |
9 | speed_limit_60 | 120 |
10 | no_entry | 209 |
11 | stop | 200 |
12 | no_u_turn | 87 |
13 | speed_camera | 90 |
14 | no_pedestrian | 73 |
15 | hump | 78 |
16 | round_about | 82 |
17 | no_stopping | 197 |
After finishing the labeling of the file, we divided the labeled photos into three folders, validation, train, and test, with 1656, 250, and 100 files, respectively. Then, for each train, test and validation folder, we provided two folders labels and images and placed photos and labels separately in these two folders. At the end, we placed all three folders in the images folder, zipped it, and then uploaded it to Google Drive.
In the google colab environment, we installed the yolov5 graphics card and its dependencies using the run time and with
Importing yolo network and adding our own data.yaml file, the network is ready for learning and train stage.
In the train stage, we set the photo size to 1280 pixels
, the batch size to 16
, and the number of epochs to 100
.
The learning stage of the network progressed with an average time of 10 minutes to complete each epoch, and in general, the amount of time needed to learn the network was more than the time limit of working on Google Colab, and for this reason, the total number of epochs exceeded We saved it on google drive so that after the Google Colab time is over, we can continue the network training and resume it with a new account. This feature was made possible with the resume command by giving the address to save the results on google drive. In general, neural network training with the used data lasted about 24 hours.
The growth process of the network was finally monitored as follows: This trend of network growth indicates a sufficient number of epochs, not too many and not too few, but enough. In the growth process of network learning, the overfeed or underfeed of the network was prevented by epoch control. The confusion matrices as well as the labels can be seen in the diagrams below.
In the next part, all the photos of the train were output, some of which can be seen below: