Skip to content

lpianta/SafeDrive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SafeDrive


    About the project

This Python app was developed as a Capstone Project for Strive School AI Engineering bootcamp.

The idea of the project was to implement a lightweight solution to check driver's drowsiness, head orientation and detect cellphone usage.


    How it works

The script uses MediaPipe library to detect facial landmarks and Tensorflow for object detection.

    MediaPipe implementation

MediaPipe is used to extract facial landmarks that allow us to detect eyes and other keypoints. An algorith based on Eye Aspect Ratio (check this paper for more information about it) is used to detect drowsiness. Head pose estimation is done by mathematical calculation on camera parameters and relevant keypoints detected on the face.

    Tensorflow Object Detection with MobileNet V3

The script uses a MobileNet V3 architecture pretrained on MS Coco Dataset and filtered to obtain only bounding boxes for mobile phones. A MobileNet V2 fine tuning has been done on a sample from OpenImage v6 pictures but the performance of MobileNet V3 are better, so I decided to use that for the project. The fine tuning needs more data and computational power to obtain better result: feel free to contact me for more informaitons or for the checkpoints if you want to further train it.

    Usage

  • Clone this repository and install the required packages through pip.
  • pip install -r requirements.txt
    
  • Launch the script from the command line, giving the index of the webcam you want to use as -i argument. Paths to configuration file, weights and cateogries names are configured by default, but you can specify it as follow:
    python safedrive.py -c path/to/config.pbtxt -w path/to/weights.pb -n path/to/names -i 0
    

    Camera index changes from system to system and depends also on the number of webcam you have, usually 0 is for the main one but if it doesn't work you may have to test it with 1, 2, and so on.

  • You can also download the entire mobilenet_v3 model from here and extract it wherever you want, but keep in mind that you'll need the file coco.names present in the "models" folder.



    If you want to test single features, in the scripts folder there are splitted python files for drowsiness detection and head pose estimation.

About

Drowsiness, head pose and smartphone detection in real time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages