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."

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using RiyaTyagi/smarttraffic-ai 1