Skip to content

Using YOLOv5 and Image Processing for Detect Traffic State.

Notifications You must be signed in to change notification settings

duongngockhanh/traffic-state-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Traffic State Detection

Object Detection

Dataset

  • It consists of 3,849 photos collected from various sources, from the Internet or from videos taken on highways and roads in Hanoi.
  • Various data enhancement techniques from Roboflow API and available augmentation methods of YOLO were used.
  • It includes 4 types of vehicles: car, bike, bus, truck. With the number of instances for each class as follows: 9,087 cars, 6,278 bikes, 1,138 buses, 3,976 trucks.
  • The dataset is divided according to the ratio: 70/20/10.
  • All images are processed in the standard size of 640x640 before being used for training.

Configuration

  • Three models were trained: YOLOv5n, YOLOv7, and YOLOv8n, using pre-trained models available in open-source, with a training of 100 epochs on the same dataset.
  • They were trained on Google Colab with a GPU configuration of Tesla K80 and 12GB of RAM.
  • They were tested on a MacBook Pro 2015 with an Intel Core i5 Dual Core CPU and 16GB of RAM.

Result

Model params (M) FLOPs (B) Size Speed (ms) mAP@50 mAP@50-95
YOLOv5n 1.9 4.5 640 104.6 96.2% 67.5%
YOLOv8n 3.2 8.7 640 178.3 96.8% 70.9%

Congestion Classification

Algorithm

  • In this problem, traffic congestion classification is determined through the calculation of the ratio x between the total area of bounding boxes surrounding the detected vehicles (V) and the area of the region of interest (R), assuming that each pixel is a unit of area.
  • The region of interest is the area where the detection and counting of vehicles will be performed. It is drawn immediately after running the program.
  • Below is the area of the region of interest, R.

image

- Below is the total area of the bounding boxes, V.

image

The ratio V/R is then mapped to a balanced scale and passed through a sigmoid function to distinguish more clearly between two states: congestion and normal.

Result

The result indicates a normal traffic state.

image

The result indicates a traffic congestion state.

image

About

Using YOLOv5 and Image Processing for Detect Traffic State.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published