The AI Traffic Management System is an end-to-end solution designed to reduce urban congestion by dynamically adjusting traffic signal timings based on real-time vehicle density. The system utilizes computer vision for vehicle detection and a high-performance genetic algorithm to optimize traffic flow at four-way intersections.
- Data Ingestion: The system receives video feeds from four cameras (one per lane) or processes uploaded video files.
- Vehicle Detection: YOLOv4-tiny identifies and counts vehicles in each frame, categorizing them to estimate lane pressure.
- Traffic Optimization: The vehicle counts are passed to a Genetic Algorithm implemented in C++17. This algorithm simulates various timing scenarios to find the configuration that minimizes total waiting time.
- Signal Implementation: The optimized green-light durations are returned to the dashboard for monitoring and implementation.
- Object Detection: Implements YOLOv4 (You Only Look Once) via OpenCV's DNN module for high-speed vehicle identification.
- Optimization Engine: Uses a Genetic Algorithm (GA) written in C++ for performance. The GA evolves a population of signal timing solutions to find a near-optimal balance for the intersection.
- Real-time Analytics: A React-based web interface provides live visualizations of traffic density and system performance.
- Flexible Deployment: Support for Docker and Docker Compose ensures the system can be deployed on edge devices or central servers with minimal configuration.
- RTSP Support: Capable of streaming directly from IP cameras for production environments.
| Layer | Technologies |
|---|---|
| Frontend | React |
| Backend API | Flask (Python 3.10) |
| Vision Processing | OpenCV, Darknet (YOLOv4) |
| Optimization Core | C++17, OpenMP [parallel..] |
| Infrastructure | Docker, Docker Compose, Nginx |
Important
Prerequisites Make sure your system has
- Docker Engine 20.10 or higher
- Docker Compose 2.0 or higher
- Minimum 8GB RAM recommended for AI model inference
The project includes a Makefile to automate common deployment tasks. For detailed information regarding containerization and orchestration, please refer to the Docker Documentation.
-
Clone the repository
git clone https://github.com/udaykiriti/TrafficManagementSystem cd TrafficManagementSystem -
Initialize the environment This command downloads the required YOLO weights and builds the Docker containers.
make setup
-
Start the services
make up
Web Dashboard
http://localhost:3000
User interface for monitoring and control.
Backend API
http://localhost:5000
REST API endpoints.
API Health Check
http://localhost:5000/health
Verify backend service status.
Full project documentation is available in the docs/ directory.
The application is fully containerized using Docker and Docker Compose. This ensures a consistent environment for both development and production. For comprehensive instructions on building, running, and troubleshooting the Docker containers, see the Detailed Docker Guide.
| Command | Description |
|---|---|
make setup |
Downloads model weights and builds Docker images. |
make up |
Starts all services in the background. |
make dev |
Starts services in development mode with hot-reloading enabled. |
make logs |
Displays real-time output from all service containers. |
make down |
Stops and removes all running containers. |
make clean |
Removes containers, volumes, and local images. |
make help |
Lists all available Makefile targets. |
For environments where Docker is not available, follow these steps:
- Install Python dependencies:
pip install -r backend/requirements.txt - Download YOLO weights:
cd backend && bash download.sh - Compile the optimization engine:
g++ -std=c++17 -O3 -fopenmp -o backend/Algo1 backend/Algo.cpp - Start the Flask server:
python backend/app.py
- Install Node dependencies:
cd frontend && npm install - Start the development server:
npm start
- Fork the project.
- Create a feature branch (
git checkout -b <feature/OptimizationUpdate>). - Commit your changes (
git commit -m "Improve GA convergence speed"). - Push to the branch (
git push origin feature/OptimizationUpdate). - Open a Pull Request.
- AlexeyAB/darknet: For the YOLOv4 implementation[not done yet.].
- OpenCV Team: For the vision processing libraries.
- Genetic Algorithm: Core logic based on standard evolutionary strategy principles.