Downloads · 30 days
0
RiyaTyagi/smarttraffic-ai
smarttraffic-ai is a machine learning model from RiyaTyagi. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Built by Riya Tyagi | Research Project for Oxford MSc Application
Downloads · 30 days
0
Access
Public
Updated Jul 5, 2026
Repo size
12.8 MB
Likes
3
Public
Click a slice to open those files.
.pt12.8 MB · 100%
From the Hugging Face model README
Built by Riya Tyagi | Research Project for Oxford MSc Application
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 |
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
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
Copy yolov8n.pt into the smarttraffic/ folder.
cd smarttraffic
python app.py
http://localhost:5000
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
The system generates a full report including:
| Layer | Technology |
|---|---|
| Backend | Python, Flask |
| AI Detection | Ultralytics YOLOv8 |
| Video Processing | OpenCV |
| Audio Analysis | Librosa, SoundFile |
| Audio Extraction | FFmpeg |
| Frontend | HTML, CSS, Vanilla JS |
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
"Laws exist. Enforcement doesn't. AI bridges the gap."