This project implements a Drowsiness Detection System using Convolutional Neural Networks (CNNs) and Transfer Learning with MobileNetV2.
It can predict whether a person is drowsy (eyes closed, yawning) or alert (eyes open, not yawning) in real time using webcam feedback.
The model supports two approaches:
- Single-task classification → Classifies into 4 categories (
open,closed,yawn,no_yawn).
We use the Yawn-Eye Dataset (NEW).
The dataset contains labeled images of:
- Open eyes
- Closed eyes
- Yawning
- Not yawning
data/
│── train/
│ ├── Open/
│ ├── Closed/
│ ├── Yawn/
│ └── No_Yawn/
│── test/
Clone this repository and install dependencies:
git clone https://github.com/yourusername/drowsiness-detection.git
cd drowsiness-detection
pip install -r requirements.txtRun the Jupyter Notebook:
jupyter notebook drowsiness-detection.ipynbThe notebook supports:
- Data preprocessing & augmentation
- Transfer learning with MobileNetV2
- Class balancing using weights
- Callbacks (early stopping, learning rate scheduling, checkpointing)
- Evaluation (accuracy, loss curves, confusion matrices)
Once trained, you can run the webcam demo:
python webcam_demo.pyThis will:
- Capture live video
- Detect face, predict eye state & yawning
- Overlay results on the video feed
Press q to exit.
- Single-task model: Improved validation accuracy.
- Optimized training (with dropout, L2, fine-tuning, augmentation): Improved generalization.
- If validation accuracy is much lower than training → increase augmentation, dropout, or reduce fine-tuned layers.
- If webcam feed is laggy → reduce input size from
224x224to128x128. - If dataset is imbalanced → use
class_weightduring training.
See requirements.txt.
MIT License.
Feel free to use and modify this project for research and learning.