The AI Traffic Management System is an intelligent urban traffic optimization platform designed to dynamically control traffic signals using real-time vehicle density analysis.
The system integrates:
- Computer Vision (YOLO-based vehicle detection)
- Genetic Algorithms (signal timing optimization)
- Reinforcement Learning (adaptive refinement)
Its primary objective is to minimize overall vehicle waiting time and improve traffic flow efficiency across multi-lane intersections.
The system follows a modular, loosely-coupled architecture composed of four core components:
- Framework: React.js
- Purpose: Interactive monitoring and control dashboard
- Uploads video feeds for traffic simulation
- Displays real-time vehicle statistics
- Visualizes optimized traffic signal durations
- Shows analytics and historical data trends
- Framework: Flask (Python)
- Role: Central coordination engine
- Handles video ingestion and validation
- Triggers vehicle detection pipeline
- Invokes the C++ optimization engine
- Applies Reinforcement Learning refinement
- Manages logging, analytics, and persistence
- Returns structured JSON responses to frontend
- Model: YOLOv4 / YOLOv4-tiny
- Library: OpenCV (DNN module)
- Detects vehicles across four lanes simultaneously
- Counts vehicle instances per frame
- Computes lane-wise vehicle density vectors
A structured vehicle density vector:
[density_lane_1, density_lane_2, density_lane_3, density_lane_4]
This vector is passed to the optimization core.
- Language: C++17
- Algorithm: Genetic Algorithm (GA)
- Executable:
Algo1
- Simulates thousands of traffic signal timing combinations
- Evolves candidate solutions across generations
- Minimizes total vehicle waiting time
- Outputs the optimal green-light duration per lane
- Implemented in Python
- Adjusts GA results using:
- Historical optimization logs
- Time-of-day patterns
- Traffic behavior trends
The system follows this execution pipeline:
User provides:
- 4 uploaded video files (one per lane), OR
- 4 live RTSP camera streams
-
Detection Phase
- YOLO model detects and counts vehicles per lane.
-
Optimization Phase
- Vehicle counts are passed to the C++ executable (
Algo1). - The Genetic Algorithm evolves signal timing configurations.
- Vehicle counts are passed to the C++ executable (
-
Refinement Phase
- The best GA candidate is adjusted by the RL agent.
The backend returns a structured JSON response:
{
"lane_1": 32,
"lane_2": 18,
"lane_3": 25,
"lane_4": 15
}These values represent optimized green-light durations (in seconds).
| Path | Description |
|---|---|
frontend/ |
React dashboard source code |
backend/ |
Flask API, AI models, and orchestration logic |
backend/Algo.cpp |
Genetic Algorithm implementation (C++) |
backend/app.py |
Flask application entry point |
backend/yolov4.py |
Vehicle detection logic |
backend/data/ |
Generated logs and analytics |
docs/ |
Project documentation |
Makefile |
Operational commands and automation |
Standard web interaction mode.
make uppython app.pyHeadless execution for real-time traffic streams.
python app.py --real --camera <url1> <url2> <url3> <url4>- Prints optimized signal durations to console
- Logs results to CSV files
The system persists performance metrics inside:
backend/data/
-
results.csv
Logs each optimization run (input densities vs. output timings) -
analytics.csv
Stores aggregated system performance metrics for long-term analysis
Important
Analytics files grow over time. Consider periodic cleanup or database migration for production deployments.
- Modular and loosely coupled architecture
- Hybrid optimization (GA + RL)
- Deterministic core with adaptive refinement
- Scalable for multi-intersection deployment
- Container-ready (Docker support)
- Multi-intersection coordination
- Edge device GPU acceleration
- Distributed optimization engine
- Real-time traffic prediction models
- WebSocket-based live dashboard updates