A computer vision-based drowsiness detection system that uses YOLO (You Only Look Once) object detection to identify drowsy and awake states in real-time video streams.
- Real-time Detection: Monitor drowsiness levels in live video feeds
- YOLO-based Model: Uses Ultralytics YOLO for accurate object detection
- Multiple Input Sources: Support for webcam, video files, and images
- 17-Class Detection: Includes drowsy/awake states plus various other objects
- Cross-platform: Works on Windows, macOS, and Linux
- Python 3.8 or higher
- Webcam or video input device
- Sufficient RAM for real-time processing
pip install -r requirements.txtKey dependencies include:
- Ultralytics (≥8.0.0) - YOLO model framework
- OpenCV (≥4.8.0) - Computer vision operations
- PyTorch (≥2.0.0) - Deep learning framework
- NumPy (≥1.26.0) - Numerical computations
Drowsiness-Detection/
├── data/ # Training and validation data
├── Detect/ # Detection scripts
│ ├── detect_real_time.py # Real-time webcam detection
│ ├── detect_video.py # Video file detection
│ └── img_detect.py # Image detection
├── Scripts/ # Utility and data processing scripts
│ ├── collect_img_test.py # Test image collection
│ ├── validation.py # Data validation
│ ├── check_data.py # Data integrity checks
│ ├── cnt_img.py # Image counting utility
│ └── cnt_labels.py # Label counting utility
├── Test/ # Test data and results
├── runs/ # Training outputs and results
├── main.ipynb # Main Jupyter notebook
├── data.yaml # Dataset configuration
└── requirements.txt # Python dependencies
git clone <repository-url>
cd Drowsiness-Detectionpip install -r requirements.txtpython Detect/detect_real_time.pypython Detect/detect_video.py --source path/to/video.mp4python Detect/img_detect.py --source path/to/image.jpgThe system is configured for 17 classes as defined in data.yaml:
- Drowsiness Classes:
awake,drowsy - Other Objects:
person,car,tv,cat,dog, and various food items
from Detect.detect_real_time import detect_drowsiness
# Start real-time drowsiness detection
detect_drowsiness()from Detect.detect_video import process_video
# Process video file for drowsiness detection
process_video("input_video.mp4", "output_video.mp4")from Detect.img_detect import detect_image
# Analyze single image
results = detect_image("test_image.jpg")The project uses YOLO models trained on custom drowsiness detection datasets. Training configurations and results are stored in the runs/ directory.
- Training Images:
data/images/ - Validation Images:
data/images/ - Test Images:
data/test/
jupyter notebook main.ipynbpython Scripts/validation.py
python Scripts/check_data.pypython Scripts/cnt_img.py # Count images
python Scripts/cnt_labels.py # Count labels- The system requires a webcam for real-time detection
- Ensure sufficient lighting for optimal detection accuracy
- Model performance may vary based on hardware capabilities
- For best results, position the camera to capture clear facial features
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source. Please check the repository for specific licensing information.
If you encounter any issues or have questions:
- Check the existing documentation
- Review the Jupyter notebook examples
- Open an issue in the repository
- Check the utility scripts in the
Scripts/folder for debugging
Happy detecting! 🚀