YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
SmartTraffic AI π¦
Speed + Helmet + Horn Violation Detector for Indian Roads
Built by Riya Tyagi | Research Project for Oxford MSc Application
π― What This Does
Upload any traffic video β Get an AI-annotated output video showing:
| Feature | How |
|---|---|
| π Vehicle Detection | YOLOv8 (car, truck, bus, motorcycle) |
| π¨ Speed Estimation | Pixel displacement + FPS calibration |
| βοΈ Helmet Detection | HSV color analysis on rider head region |
| π Horn Detection | Librosa spectral analysis (800β3500 Hz range) |
| π’ Noise Level (dB) | RMS energy per audio window |
| π¨ Violation Alerts | Real-time on-screen banner + stats |
βοΈ Indian Law Context (Motor Vehicles Act, 1988)
- Section 194F: Honking in silence zones β βΉ1,000 (1st offence), βΉ2,000 (repeat)
- Pressure horns in Delhi: Fine up to βΉ12,000
- Night honking (10 PM β 6 AM): Minimum βΉ1,000 fine
- Silence zones: Within 100m of hospitals, courts, schools (40β50 dB limit)
- Problem: Only 0.22% of traffic challans issued for horn violations β This AI system automates enforcement!
π Project Structure
smarttraffic/
βββ app.py # Flask backend β detection pipeline
βββ templates/
β βββ index.html # Beautiful frontend UI
βββ yolov8n.pt # YOLOv8 model weights (copy here)
βββ uploads/ # Temp uploaded videos
βββ outputs/ # Processed output videos
π Setup & Run
1. Install Dependencies
pip install flask ultralytics opencv-python-headless librosa soundfile
Also make sure ffmpeg is installed:
# Ubuntu/Debian
sudo apt install ffmpeg
# macOS
brew install ffmpeg
# Windows β download from https://ffmpeg.org/download.html
2. Place your YOLOv8 model
Copy yolov8n.pt into the smarttraffic/ folder.
3. Start the server
cd smarttraffic
python app.py
4. Open in browser
http://localhost:5000
π¬ How Horn Detection Works
Video Input
β
βββ Video frames βββ YOLOv8 βββ Vehicle tracking + Speed estimation
β
βββ Audio track βββ ffmpeg extract βββ Librosa analysis
β
βββββββββββββ΄ββββββββββββ
β Spectral analysis β
β β’ RMS energy (loud?) β
β β’ Centroid 800β3500Hz β
β β’ Low ZCR (pure tone) β
βββββββββββββ¬ββββββββββββ
β
Horn event detected?
YES β Mark timestamp
NO β Skip
Combine: Horn timestamp β closest vehicles in frame β VIOLATION ALERT
π Output Stats
The system generates a full report including:
- Total vehicles detected
- Average & maximum speed (km/h)
- Helmet vs no-helmet count
- Number of horn/noise events
- Average noise level (dB)
- Horn event timeline with timestamps
π§ͺ Tech Stack
| Layer | Technology |
|---|---|
| Backend | Python, Flask |
| AI Detection | Ultralytics YOLOv8 |
| Video Processing | OpenCV |
| Audio Analysis | Librosa, SoundFile |
| Audio Extraction | FFmpeg |
| Frontend | HTML, CSS, Vanilla JS |
π Research Paper
This project is the basis for a research paper:
"Smart Traffic Violation Detection for Indian Urban Roads: Real-Time Vehicle Speed Estimation and Aggressive Horn Noise Classification Using YOLOv8 and Deep Learning"
Target publication: IEEE Conference on Intelligent Transportation Systems
π Academic Context
- Author: Riya Tyagi, B.Tech CSE (AI & ML), Galgotias College of Engineering
- Purpose: Research paper + Oxford MSc Application portfolio
- Problem addressed: Delhi noise pollution (90 dB peak vs WHO limit 55 dB)
- Real-world impact: Automates enforcement of Section 194F, Motor Vehicles Act 1988
"Laws exist. Enforcement doesn't. AI bridges the gap."
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support