Real-time drowsiness detection system that uses YOLOv5 for face/eye detection and LSTM for fatigue classification based on temporal patterns. This AI-based solution aims to enhance driver safety by detecting early signs of drowsiness.
- π₯ Real-time webcam integration
- ποΈ Eye and face detection using YOLOv5
- β±οΈ Temporal sequence modeling with LSTM
- π§ Custom labeled dataset (awake/drowsy)
- π Performance monitoring in Jupyter
- π§ Modular design for easy training and customization
-
YOLOv5 model detects face and eyes from webcam feed.
-
Eye regions are cropped and passed to a trained LSTM classifier.
-
LSTM analyzes a sequence of frames to determine the state:
- π’
Awake - π΄
Drowsy
- π’
The system reacts instantly and overlays the prediction label with bounding boxes on the live feed.
Labels are well-distributed in terms of position and size. Balanced annotation increases detection accuracy.
Awake class achieves high precision at lower confidence thresholds, while drowsy class stabilizes later.
- Awake: 0.948
- Drowsy: 0.861
- mAP@0.5: 0.905
Indicates a reliable and balanced detection model.
High recall even at low confidence thresholds suggests effective detection capability.
Loss values decrease steadily and performance metrics increase over epochs, showing good training convergence.
Sample training images with labels. Variations in expression, angle, and lighting enhance model generalization.
Predictions match the ground truth closely, validating model reliability.
driver_drownise_detection_Program/
βββ data/
βββ datasets/
βββ labelimg/
βββ yolov5/
βββ yolov5s.pt
βββ train_lstm.py
βββ main.py
βββ Drowsiness Detection Tutorial.ipynb
βββ requirements.txt
βββ README.md
git clone https://github.com/alinb/drowsiness-detection.git
cd drowsiness-detection
pip install -r requirements.txtYOLOv5 repo must be cloned under
yolov5/:
git clone https://github.com/ultralytics/yolov5.gitcd yolov5
python train.py --img 640 --batch 16 --epochs 100 --data ../data/data.yaml --weights yolov5s.ptpython train_lstm.py --data_dir datasets/ --epochs 50 --batch_size 32python main.pyThe project demonstrates that combining object detection with temporal sequence modeling (YOLO + LSTM) can effectively solve real-world problems such as driver fatigue monitoring. Future improvements could include:
- Adding audio alerts
- Deploying on mobile devices with TFLite
- Expanding the dataset with night-time/low-light scenarios
MIT Β© 2025 Ali Nebi Er
Built with support from OpenAI's GPT-4 and the YOLOv5 community.















