Driver fatigue and drowsiness are among the leading causes of road accidents, especially during night-time long-haul driving such as truck and highway transport. Traditional safety measures fail because they do not monitor the driver’s physical alertness in real time.
There is a strong need for a real-time, automated, and intelligent system that can:
- Continuously monitor a driver
- Detect whether the driver is awake or drowsy
- Trigger alerts before an accident occurs
- Be extendable to IoT-based safety systems
This project implements a real-time drowsiness detection system using Deep Learning and Computer Vision. Working Video
- Train a binary image classification model (
AwakevsDrowsy) - Use a pretrained ResNet-18 for robust feature extraction
- Perform live face detection via webcam
- Predict driver state in real time
- Raise alerts if drowsiness persists
- CNNs capture facial fatigue patterns
- Transfer learning improves accuracy with limited data
- Temporal frame tracking reduces false positives
Pipeline Flow:
Webcam Frame
↓
Face Detection (OpenCV Haar Cascade)
↓
Face Cropping & Preprocessing
↓
ResNet-18 Classifier
↓
Awake / Drowsy Prediction
↓
Alert Trigger (if drowsy persists)
- Language: Python
- Deep Learning: PyTorch, Torchvision
- Model: ResNet-18 (Transfer Learning)
- Computer Vision: OpenCV
- Image Processing: Pillow, NumPy
- Dataset Handling: YOLO-style labels
- Deployment Ready: IoT & Edge-compatible
├── datapreprocessing.py # Dataset loading & preprocessing
├── ResNetmodel.py # Model training & saving
├── runmodel.py # Real-time webcam inference
├── requirements.txt # Project dependencies
├── drowsiness_detection_model.pth # Trained model (generated)
└── README.md
pip install -r requirements.txtEnsure the dataset follows this structure:
images/
├── img1.jpg
├── img2.jpg
labels/
├── img1.txt
├── img2.txt
Label format (YOLO-style):
0 → Awake
1 → Drowsy
python datapreprocessing.pyThis step:
- Splits dataset into train/test
- Saves metadata and NumPy arrays (optional)
python ResNetmodel.pyThis will:
- Train ResNet-18 on your dataset
- Save the trained model as:
drowsiness_detection_model.pth
python runmodel.pyControls:
- Webcam opens automatically
- Press
qto exit
- Green Box: AWAKE
- Red Box: DROWSY
- Alert Trigger: If drowsiness continues for multiple frames, a DROWSINESS ALERT is displayed.
-
🚛 Truck & Bus Driver Monitoring
-
🚗 Night-time highway safety
-
🏭 Industrial machine operator alertness
-
🧠 Workplace fatigue monitoring
-
🔌 IoT integration with:
- Buzzers
- Seat vibration
- Smart dashboards
- Fleet monitoring systems
- Eye Aspect Ratio (EAR) + blink analysis
- Temporal models (LSTM / sliding window)
- Face detection upgrade (MTCNN / RetinaFace)
- Edge deployment (Jetson / Raspberry Pi)
- IoT alerts (GSM / MQTT / CAN bus)
- Driver fatigue analytics dashboard