Skip to content

This is a system which can detect the drowsiness of the driver using CNN - Python, OpenCV

License

Notifications You must be signed in to change notification settings

satyamgeek/driver_drowsiness_system_CNN

Repository files navigation

Driver_drowsiness_system_CNN

This is a system which can detect the drowsiness of the driver using CNN - Python, OpenCV

The aim of this is system to reduce the number of accidents on the road by detecting the drowsiness of the driver and warning them using an alarm.

Here, we used Python, OpenCV, Keras(tensorflow) to build a system that can detect features from the face of the drivers and alert them if ever they fall asleep while while driving. The system dectects the eyes and prompts if it is closed or open. If the eyes are closed for 3 seconds it will play the alarm to get the driver's attention, to stop cause its drowsy.We have build a CNN network which is trained on a dataset which can detect closed and open eyes. Then OpenCV is used to get the live fed from the camera and run that frame through the CNN model to process it and classify wheather it opened or closed eyes.

Setup

To set the model up:
Pre-install all the required libraries
1) OpenCV
2) Keras
3) Numpy
4) Pandas
5) OS
Download the Dataset from the link given below and edit the address in the notebook accordingly.
Run the Jupyter Notebook and add the model name in detect_drowsiness.py file in line 20.

The Dataset

The dataset which 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

CNN

Accuracy

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

The Output

  1. Open Eyes
    Open_eyes
  2. Close Eyes
    Here we detect wheater the eyes are closed and count the number of frames for which the eyes were closed (which is 10 frame) greater then that the Alarm will ring and the WARNING sign is displayed. Closed_eyes