Skip to content

mayureshagashe2105/HackDSC2021-Drowsiness-Detection-Web-app

Repository files navigation

Drowsiness Detection Web app

Prevents sleep deprivation road accidents, by alerting drowsy drivers. In this project, we have trained a convolutional neural network, to determine whether the eyes are closed or not, further, eye-patches are extracted from the face image to make all predictions. The dataset used for the training process can be accessed from the link given below:
https://www.kaggle.com/kutaykutlu/drowsiness-detection.

Working Demo

Here is the link for a demo video.

Click Here

Live Testing The App

$ pip install -r requirements.txt

Then download Eye_patch_extractor_&_GUI.py, ISHN0619_C3_pic.jpg, my_model (1).h5 & sleep.jfif files.

$ streamlit run Eye_patch_extractor_&_GUI.py

Understanding The Problem Statement

According to the survey done by 'The Times of Inidia', nearly 40% of road accidents are caused by sleep deprivation. Fatigued drivers, long-duty driving are the major causes for the same. To solve this issue, this app primarily aims to predict whether or not the driver is sleeping, if found sleeping, it alerts the driver by making a high-frequency sound. This project is to avoid such sleep deprivation accidents!

Implementation

  1. A Deep Learning Model will be trained to detect whether the driver's eyelids are open or not. This will be achieved by training a Convolutional Neural Network using Tensorflow.
  2. A web-cam will take a picture of the driver's face at regular intervals of time and the patch of the driver's eye will be extracted from that picture. This task will be achieved by using OpenCV.
  3. This patch will be further used for the prediction purpose with the model trained in step 1.
  4. Using this prediction, if the driver's eyes are closed a beep sound will be played, to alert the driver.

Protoype Insights

Preiction Page:

Keeping eyes open:

Keeping eyes closed:

Drowsiness Detetction Model Insights

This model is trained with the help of TensorFlow and is based upon convolutional neural networks. It takes RGB images with the dimensions (86 * 86 * 3).

Model Architecture

Layer NumberLayer TypeOutput ShapeTrainable ParametersActivation Funtion
1CONV2D(None, 84, 84, 75)2,100Relu
2MaxPooling2D(None, 16, 16, 75)0None
3Conv2D(None, 15, 15, 64)19,264Relu
4MaxPooling2D(None, 7, 7, 64)0None
5Conv2D(None, 5, 5, 128)73,856Relu
6MaxPooling2D(None, 2, 2, 128)0None
7Flattern(None, 512)0None
8Dense(None, 64)32,832Sigmoid
9Dense(None, 2)130Softmax

Eye Patch Extractor & Predictor Insights

This model uses OpenCV's "Haar Cascade Classifier" for face detection and after the proposal of the region of interest, it extracts the eye patch by the "Centroid Method" developed by us. These extracted features will be then passed to the trained model for Drowsiness Detection.