Skip to content

nguyenquangtung/DL_Driver-drowsiness-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Driver_drowsiness_system_CNN

This system is designed to detect driver drowsiness using Convolutional Neural Networks (CNN) in Python with the help of OpenCV. Its primary objective is to reduce the occurrence of accidents on the road by detecting if the driver is becoming drowsy and issuing an alarm as a warning.

The implementation involves utilizing Python, OpenCV, and Keras (with TensorFlow) to construct a system capable of extracting facial features from the driver's face. By detecting the status of the driver's eyes (open or closed), the system can identify if the driver is falling asleep. If the eyes remain closed for a continuous period of 3 seconds, an alarm is triggered to capture the driver's attention and prevent any potential accidents.

To achieve this, a CNN model is trained on a dataset that contains examples of both closed and open eyes. This trained model is then utilized by OpenCV to capture live video feed from the camera. Each frame from the video feed is passed through the CNN model for processing and classification, determining whether the eyes are open or closed in real-time.

More info in: https://youtu.be/X8ZFH_fZsIo?si=v64a-kkypdOt_J2y

Setup

1- To set up the environment, pre-install all the required libraries by using this:

pip install -r requirements.txt


- OpenCV
- Keras
- Numpy
- Pandas
- OS

2- Download the Dataset from the link given below and edit the address in the notebook accordingly.

3- Optional: Run the Jupyter Notebook to train your model with other custom hyper-parameter 20.

4- Run detect_drowsiness.py file for main application (change the path model to your model or use my trained model) in line 20.

The Dataset

The dataset that was used is a subnet of a dataset from(https://www.kaggle.com/datasets/dheerajperumandla/drowsiness-dataset)
it has 4 folder which are
1) Closed_eyes - having 726 pictures
2) Open_eyes - having 726 pictures
3) Yawn - having 725 pictures
4) no_yawn - having 723 pictures

The Convolution Neural Network

image

Accuracy

We did 50 epochs, to get a good accuracy from the model i.e. 98% for training accuracy and 96% for validation accuracy. image