Giter VIP home page Giter VIP logo

advanced_drowsiness_detection's Introduction

Overview

According to the National Highway Traffic Safety Administration, every year about 100,000 police-reported crashes involve drowsy driving. These crashes result in more than 1,550 fatalities and 71,000 injuries. Detecting a fatigued driver is therefore vital equipment in modern vehicles. If you don't have the money for an such a vehicle, a DIY solution with Python might be the appropriate answer ;)

For the training data we will use the real-life drowsiness video dataset provided by the University of Texas (UTA). These data are free to use for scientific or educational purposes and identities cannot be inferred based on these data only.

The real-time drowsiness dataset

UTA dataset consists of 180 RGB videos of 60 unique participants. Each video is around 10 minutes long, and is labeled as belonging to one of three classes: alert (labeled as 0), low vigilant (labeled as 5) and drowsy (labeled as 10). The labels were provided by the participants themselves, based on their predominant state while recording each video

However, we were able to download and analyze the video files of 18 participants. We extracted 240 frames per video from which we then derived the training data.

Some participants

Aim

We use the following three variants to enable real-time drowsiness detection:

  1. Feature based classification with KNN as baseline classifier
  2. A CNN with 2 convolutional layers
  3. Greedy way of drowsiness detection entirely without machine learning

It is recommended to keep the structure of the repository. Since we are not allowed/able to upload all the videos and used images, you will have to download them from UTA yourself and then copy them into the subdirectories analogous to the script. The necessary Python packages can be found in drowsiness_imports.py and in the requirements.txt.

Results (v. 0.1)

The classifiers achieve different levels of accuracy. While KNN achieves a test accuracy of about 70% through some feature engineering, the CNN classifier shows a test accuracy of about 99%. These are both very good values. However, the training data is strongly biased, which is more indicative of overfitting. Although we had used 240 images from each UTA participant, these are very similar. This is more due to the fact that there were only 18 individual persons who sat relatively motionless in front of their laptop. Here, a larger distortion would have to take place in order to achieve more reliable results. Nevertheless, the two classifiers do work in principle. If someone puts his head on the table, he is probably considered tired. If someone blinks frequently, that could also indicate fatigue. Another method - which works entirely without training data - is Option 3. Here we define a threshold value. If this is exceeded, the person is considered tired. This is based on the assumption that people who fall into a state of fatigue often have their eyes closed for longer periods of time. Accordingly, we can record in a graph and determine when a fatigue symptom has occurred.

result

Results (v. 0.2)

Some additional training data was added.

  • For the KNN classifier, over 13,235 data series were collected using the metrics MOE, EAR, MAR, Circularity and their normalised forms.
  • Currently, a total of 9,933 images of tired and awake persons are used for the CNN model, with the majority part coming from UTA video dataset.

With the new training data, the KNN classifier now achieves an F1 score of 92%, which is a significant increase over the original version. With the CNN, on the other hand no noticeable difference in terms of accuracy for the test data. It still fluctuates between 98% and 99%, which is a very good value. A closer look at the activation maps showed that the network also often learned the people's surroundings.

drowsiness

A further refinement of the network was to perform a kind of majority voted based classification. Here, the recognition system always collects an average of 20 images and notes the decisions of the classifications. If the majority of these images indicate fatigue, the person is classified as drowsy, otherwise as vigilant. This minimizes any single misclassification and gives a more stable prediction model.

Outlook

Use more unique tired persons and awake people and include more variance (e.g. different angles, ages, skins etc.). After all, a GUI for live detection is mandatory. Feel free to make further suggestions or updates ;)

advanced_drowsiness_detection's People

Contributors

hackenjoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

advanced_drowsiness_detection's Issues

Not able to obtain model

Hey, I downloaded the data but the the extract landmark doesn't detect faces in all the videos. Can you upload the model cnn_drowsiness.pt? It'd be a great help. Thanks in advance!

Can this project work without UTA dataset only with csv files?

Hello, thanks for your sharing and I wonder if it works without the UTA datasets only use the csv files? Since the dataset is too large. And if I want to test my video of drowiness driver should I extract drowiness features (kit provided in the repo) then put it in this work so I can get the results?

About the dataset

Hey. I am also working on driver drowsiness detection.
I am wondering how did you get the CSV files as I couldn't find them in the dataset folders. Did you create them on your own?
Could you also explain what are the values you stored in each column and how to use it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.