Skip to content

YOLOv5 Traffic Jam Detection: Real-time vehicle tracking and traffic congestion detection system.

License

Notifications You must be signed in to change notification settings

Kevinbui16/Traffic-Jam-Object-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv5 Traffic Jam Detection 🚦

Introduction📖

This is a project on the YOLOv5-based traffic congestion detection system using object detection on images, videos, and real-time cameras. It involves the detection of vehicles from the images and identification of the traffic congestion based on their speed and density.🚀

Motivation 🌟

Among several issues in urban centers, traffic congestion massively affects travel time and fuel consumption. If the traffic jam is detected efficiently and in real-time, it can help in effective traffic management and route planning. In this project, a robust system for detecting traffic jams is developed using the deep learning model YOLOv5.🚗🚙🚚

Data Source📊

It uses a dataset of different images and videos of the traffic scenario to train the YOLOv5 model. Further, more annotations regarding the vehicle's position and class were prepared manually to improve this model's performance.

The link to download dataset for training Yolov5:

File Descriptions 📄

  • modified_detect.py: Script for running the YOLOv5 detection inference.
  • train.py: Script for training the YOLOv5 model on the custom dataset.
  • utils/: Directory containing utility scripts for data loading, plotting, and other functions.
  • data/: Directory containing the dataset and annotations.
  • models/: Directory containing the YOLOv5 model definitions and configurations.

How to Use the Code 🤔

Usage 🔧

  1. Clone the Repository:

- git clone https://github.com/yourusername/yolov5-traffic-jam-detection.git
- cd yolov5-traffic-jam-detection

  1. Install Requirements::

- pip install -r requirements.txt

  1. Run Detection on an Image:

- python modified_detect.py --weights runs/train/exp/weights/best.pt --source data/images/your_image.jpg

  1. Run Detection on a Video:

- python modified_detect.py --weights runs/train/exp/weights/best.pt --source data/videos/your_video.mp4

  1. Run Detection on Live Camera Feed:

- python modified_detect.py --weights runs/train/exp/weights/best.pt --source 0

Testing Model 🔍

Video Predictions


Nornmal Traffic detect demo


Traffic congestion detect demo

-TensorBoard Training Visualizations after 50 epochs📈-


Precision and Recall after training


F1 and confusion matrix after training


final result

Results📝

The YOLOv5 model effectively detects traffic jams by identifying and tracking vehicle speeds and densities. The system alerts when a potential traffic jam is detected based on predefined thresholds for vehicle count and speed.

Requirements🛠️

To run this project, you will need the following libraries:

Libraries
Pytorch
sys
platform
argparse
csv
pathlib
numpy
os

About

YOLOv5 Traffic Jam Detection: Real-time vehicle tracking and traffic congestion detection system.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published