Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOLO v11 implementation #1

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# Vehicle Detection
# Traffic Management System

Using Yolo v10 nano and OpenCV to count number of vehicles in 4 simultaneous video feeds in 3FPS.
This project demonstrates a real-time Traffic Management System that detects vehicles from multiple video feeds and dynamically manages traffic lights to optimize traffic flow. The system utilizes the YOLO object detection model to count vehicles in each lane and adjusts traffic light durations accordingly based on vehicle counts in each feed.

## Features

- **Real-time Vehicle Detection:** Uses YOLO model to detect and count vehicles (e.g., cars, trucks, buses, motorbikes) from four video feeds.
- **Traffic Light Management:** Determines the optimal green light duration for each lane based on vehicle count, ensuring lanes with higher traffic receive more green light time.
- **PyQt5 Interface:** Displays vehicle counts, current traffic light status, and time remaining for each lane.
- **User-Friendly Display:** Shows all video feeds in a grid format with detected vehicle count overlay.

## Technologies Used

- **YOLO (Ultralytics)** - For vehicle detection.
- **OpenCV** - For video processing.
- **PyQt5** - For the graphical user interface.
- **NumPy** - For image and data manipulation.

## Installation

1. **Clone the repository:**
```bash
git clone <your-repo-url>
cd <repo-directory>
```

2. **Install dependencies:**
```bash
pip install -r requirements.txt
```

Ensure you have the following dependencies installed:
- OpenCV
- PyQt5
- Ultralytics YOLO
- NumPy

3. **Download the YOLO Model:**
Place your YOLO model (`yolo11n.pt`) in the `res/models/` directory.

4. **Prepare Video Files:**
Place video files (`video2.webm`, `video5.webm`, `video3.webm`, `video4.webm`) in the `res/videos/` directory.

## Usage

1. **Run the Application:**
```bash
python main.py
```

2. **Interface Overview:**
- **Traffic Count Window:** Displays each feed's vehicle count, traffic light status, and time remaining for the current green light.
- **Video Feed Window:** Shows all video feeds in a grid with vehicle count overlays.

3. **Traffic Cycle Management:**
- The system dynamically allocates green light times based on vehicle counts.
- To exit, press 'q' in the video feed window.

## Code Overview

- **YOLO Model:** Detects vehicles and counts them in each feed.
- **TrafficManager Class:** Manages traffic light cycles, setting green light duration based on detected vehicle count.
- **PyQt5 Interface:** Displays real-time updates of vehicle counts, traffic light status, and time remaining for each feed.

## Customization

To add more vehicle types or change parameters like `MIN_GREEN_TIME` or `MAX_GREEN_TIME`, modify the relevant variables in the `manage_traffic` function.

## License

This project is licensed under the MIT License.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from PyQt5 import QtWidgets, QtGui, QtCore

model = YOLO("res/models/yolov10n.pt")
model = YOLO("res/models/yolo11n.pt")

vehicle_classes = ["car", "truck", "bus", "motorbike"]

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
opencv-python
torch
torchvision
PyQt5
PyQt5
ultralytics
Binary file added res/models/yolo11n.pt
Binary file not shown.