How syrajveer/anti-accident-detection-model works
Project type and purpose
• This is a full‑stack, Deep‑Learning‑powered warning system for detecting driver inattention or dangerous behavior in real time.
• The Python/Flask “backend” hosts endpoints that accept a video stream or file, run a trained InceptionV3‐based model plus computer‐vision routines, and return warnings. The “frontend” is a simple web UI (HTML/CSS/ JS) that streams video, displays alerts, and plays an alarm sound.
File structure
• Top‑level application:
• app.py – Flask app defining HTTP routes, loading models, orchestrating inference.
• inceptionv3.h5 / inceptionv3.pkl – trained Deep Learning model files.
• model.js – client‑side JavaScript (likely handles video capture/streaming).
• alarm.wav – audio alert resource.
• requirements.txt – Python dependencies (Flask, Keras, OpenCV, etc.).
• Templates directory:
• index.html – main UI page.
• style.css – styling.
• Test_Video_s.mp4 – sample video for local testing.
• Notebooks: main_Code.ipynb – data exploration, model training pipeline.
• Configuration: LICENSE, README, PPTX demo.
Key architectural insights from README
• System ingests live or uploaded dashboard camera feed.
• Pipeline combines face detection, eye tracking, head‐pose estimation, feeding features to a Deep Neural Network.
• Outputs real‑time alerts (visual + alarm.wav).
• No external database; state is ephemeral per session.
Main components
a. Frontend (Browser)
• HTML/CSS (templates/index.html, style.css)
• JavaScript (model.js) for video capture, streaming to backend, rendering results, playing alarm.wav
b. Backend (Flask)
• app.py orchestrates endpoints:
• / → serves index.html
• /predict (or similar) → accepts video frames or file via HTTP POST/WebSocket
• Preprocessing modules (OpenCV) for face/eye/head‐pose extraction
• Model inference module (loads inceptionv3.h5/.pkl via Keras)
c. Machine Learning Model
• InceptionV3‐based network for classification of “safe” vs “attention‐required” states
d. Notification subsystem
• Alarm.wav triggered by the frontend or backend event
e. (Optional) Training Pipeline
• Jupyter notebook showing data collection, preprocessing, training steps
Relationships and data flows
• Browser captures video → streams frames via HTTP/WebSocket → Flask receives frames → OpenCV face/eye/head‐pose processing → feature tensor → Keras model inference → classification result back to frontend → UI updates overlay + plays alarm.wav
• For testing: frontend can POST Test_Video_s.mp4 instead of live camera.
• No persistent storage or external services; purely synchronous request/response.
Architectural patterns & design principles
• MVC/lightweight “view” in templates, “controller” in app.py, “model” in Keras code
• Separation of concerns:
• Presentation (HTML/CSS/JS)
• Application logic (Flask routes)
• ML logic (preprocessing + inference)
• Single‑process, single Docker/container potential deployment (not microservices).