How rudrabarad/driver-drowsiness-detection works
Project type and purpose
• This is an open-source computer-vision + deep-learning application for real-time driver drowsiness detection.
• It offers two pipelines:
• A custom CNN approach (folder: DDDS_CNN)
• A Transfer Learning approach (folder: Transfer_learning)
• Both capture live video, detect facial features, classify eye state, and trigger an alarm if drowsiness is detected.
File structure
Top level:
• DDDS_CNN/ – Python scripts for your custom CNN pipeline
– Dataset.txt – URLs for raw images
– haar cascade files/ – face & eye detectors (XMLs)
– model_training.py – trains custom CNN & saves model
– main_capture.py – live camera inference & alarm
• Transfer_learning/ – Jupyter notebook & helper scripts for TL pipeline
– get_dataset.txt – URLs for TL dataset
– data_prep.py & data_dist.py – preprocessing & train/test split
– Model_Training_TL.ipynb – trains TL model & saves it
– tl_capture.py – live camera inference & alarm
• alarm.wav – sound file used by both pipelines
• Research Article.docx, Video_Demonstration.mkv – documentation & demo
• README.md & LICENSE
Key insights from the README
• Lists required libraries (Keras, OpenCV, Pygame, NumPy, etc.)
• Describes training vs. inference steps for both approaches
• Shows performance metrics for each model
• Notes that model files are generated at training time
Components
a. Main components
1. Data Acquisition
– Dataset URLs (Dataset.txt / get_dataset.txt)
– Raw image folders (downloaded externally)
2. Data Preprocessing
– data_prep.py, data_dist.py (Transfer Learning)
– optional augmentation / resizing
3. Model Training
– model_training.py (Custom CNN)
– Model_Training_TL.ipynb (Transfer Learning)
– Output: saved .h5 (or similar) model file(s)
4. Inference / Runtime
– Video Capture module (OpenCV)
– Haar Cascade detectors (face, left eye, right eye)
– Model Inference (Keras -> open-vs-closed classification)
– Alarm module (Pygame + alarm.wav)
5. External Interfaces / Artifacts
– Research Article & Video Demo
– Logs / Metrics / Saved model versions
b. Relationships & Data Flow
• Data Acquisition → Data Preprocessing → Model Training → Saved Model
• Saved Model + Haar Cascades + Live Video Stream → Inference Engine
• Inference Engine → Decision Logic (open vs. closed eyes) → Alarm Module → Audio Output
• (Optional) Inference metrics → Log / Console
c. Architectural patterns & design principles
• Modularity: separate training vs. inference code paths
• Reusability: shared alarm.wav & Haar cascades
• Pipeline pattern: data → preprocess → train/infer → output
• Extensibility: ability to plug in new models (e.g., improved CNN or TL checkpoint)
d. Key technologies & libraries
• Python, OpenCV (cv2) for video and face detection
• Keras (TensorFlow backend) for model definition & inference
• Pygame for alarm sound playback
• Numpy / glob / tqdm / Matplotlib for data handling & visualization
• Jupyter Notebook for interactive TL training