Real-Time AI-Powered Advanced Driver Assistance System (ADAS) for Indian Roads
β¨ Features β’ ποΈ Architecture β’ βοΈ Tech Stack β’ π Quick Start β’ πΈ Dashboard β’ π Project Structure β’ π§ Models β’ π Deployment
- Custom YOLO11m fine-tuned on BDD100K, IDD (Indian Driving Dataset), and DAWN (weather-degraded) datasets
- Detects vehicles, pedestrians, cattle, auto-rickshaws, motorcycles, and stray animals
- MiDaS monocular depth estimation for distance perception without LiDAR
- Indian road danger weighting β objects are scored by class-specific weights (e.g., pedestrian/cow = 1.0, car = 0.6)
- MediaPipe Face Landmarker (468-point facial mesh) for precise face tracking
- EAR (Eye Aspect Ratio) β real-time drowsiness detection
- PERCLOS β percentage of eyelid closure over time
- MAR (Mouth Aspect Ratio) β yawn detection
- 6-DoF Head Pose Estimation β distraction and head nod detection
- Dual-stream fusion: 40% road hazard + 60% driver state β unified risk score
- Risk levels: LOW π’ / MEDIUM π‘ / CRITICAL π΄
- Real-time WebSocket streaming to live dashboard
- Side-by-side video panels with annotation overlays
- Live risk score bars and rolling analytics charts
- Alert feed with animated entries
- Upload road/cabin videos for batch processing
Road Camera (forward-facing) Cabin Camera (driver-facing)
| |
v v
[YOLO11m Detection] [MediaPipe Face Landmarks]
(vehicles, cattle, (468-point facial mesh)
pedestrians, auto-rickshaws) |
| +----+----+
v | | |
[MiDaS Depth Estimation] [EAR] [MAR] [PERCLOS]
(monocular depth map) | | |
| [Head Pose] [Nod Detection]
v | |
[Indian Road Danger v v
Weighting Algorithm] [Driver State Fusion]
(object class x proximity) (weighted: 30% EAR, 25% PERCLOS,
| 20% MAR, 15% nod, 10% pose)
v |
[Road Hazard Score] |
| |
+----------+-------------------+
|
v
[Risk Fusion Engine]
(40% road + 60% driver)
|
v
[Unified Risk Score]
(LOW / MEDIUM / CRITICAL)
|
v
[WebSocket Stream]
+ [Annotated Video Output]
| Component | Technology |
|---|---|
| Language | Python 3.11 |
| Web Framework | FastAPI (async) |
| ASGI Server | Uvicorn |
| Real-time | WebSockets |
| Object Detection | Ultralytics YOLO11m (fine-tuned) |
| Depth Estimation | MiDaS (MiDaS_small) |
| Face Tracking | MediaPipe Face Landmarker |
| Computer Vision | OpenCV, NumPy, SciPy |
| ML Framework | PyTorch |
| Component | Technology |
|---|---|
| Language | JavaScript (ES Modules) |
| UI Framework | React 19 |
| Build Tool | Vite 8 |
| Styling | Tailwind CSS v4 |
| Animation | Framer Motion |
| Charting | Recharts |
| Icons | Lucide React |
| Linting | ESLint 10 |
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# .\venv\Scripts\Activate # Windows
# Install dependencies
pip install -r requirements.txt
# Download model weights
python download_weights.py
# Run server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
# Install dependencies
npm install
# Set backend URL (optional, defaults to localhost:8000)
echo "VITE_API_URL=http://localhost:8000" > .env
# Run development server
npm run devOpen http://localhost:5173 in your browser.
cd backend
docker build -t drivesafe-backend .
docker run -p 7860:7860 drivesafe-backendThe DriveSafe dashboard is a futuristic HUD-style interface featuring:
- Dual Video Panels β side-by-side road (left) and driver (right) feeds with real-time annotations
- Control Panel β upload road/cabin videos, Run/Stop/Reset analysis
- Risk Badge β animated LOW/MEDIUM/CRITICAL indicator
- Score Panel β live road hazard score, driver state score, and fused risk score
- Analytics Chart β rolling time-series of all three scores
- Alert Feed β real-time alerts for detected events (drowsiness, yawning, objects, etc.)
DriveSafe/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI entry point & routes
β β βββ config.py # Environment configuration
β β βββ annotators/ # Frame annotation overlays
β β βββ models/
β β β βββ yolo/ # YOLO11m detection pipeline
β β β βββ depth/ # MiDaS depth estimation
β β β βββ driver/ # MediaPipe face & metrics
β β βββ processors/ # Processing pipeline orchestrators
β β βββ websocket/ # WebSocket real-time streaming
β β βββ utils/ # Image utilities
β βββ weights/ # Model weight files
β βββ requirements.txt # Python dependencies
β βββ requirements-hf.txt # HuggingFace-optimized deps
β βββ Dockerfile # Multi-stage Docker build
β βββ download_weights.py # Weights downloader
β
βββ frontend/
βββ src/
β βββ pages/ # Page components
β βββ sections/ # Landing page sections
β βββ components/
β β βββ dashboard/ # Live dashboard components
β β βββ analytics/ # Score & chart components
β β βββ cards/ # Reusable card components
β β βββ ui/ # Base UI primitives
β β βββ hero/ # Hero section components
β β βββ layout/ # Navbar & layout
β βββ services/api.js # REST + WebSocket client
β βββ styles/globals.css # Tailwind v4 theme
βββ package.json # NPM dependencies
βββ vite.config.js # Vite configuration
βββ vercel.json # Vercel deployment
βββ .env.example # Environment template
| Model | Source | Purpose |
|---|---|---|
| YOLO11m (fine-tuned) | Ultralytics + custom training on BDD100K, IDD, DAWN | Object detection for Indian road hazards |
| MiDaS_small | Intel ISL (torch.hub) | Monocular depth estimation |
| FaceLandmarker | Google MediaPipe | 468-point facial landmark detection |
Weights are downloaded automatically via download_weights.py.
The frontend includes a vercel.json for SPA deployment:
cd frontend
npm run build
vercel --prodThe backend includes a Dockerfile configured for Hugging Face Spaces with sdk: docker.
- Real-time camera input (USB/RTSP) in addition to video upload
- Multi-session concurrent processing with isolated driver state
- Unit & integration tests
- Mobile companion app
- On-device edge deployment (NVIDIA Jetson / Raspberry Pi)
- Additional Indian-specific hazard classes (speed bumps, potholes)
MIT