Youtube: watch
Try it out: download
- Window 10 OS
Install Python version 3.9.6 and run the following command to install all required python packages
pip install -r requirements.txtDrowsiness custom dataset is generated by running prepare.py script and are placed under data folder. There are three labels for the drowsiness data:
- Awake
- Background
- Drowsy
Background label indicates situation whenever user is not sitting in front of the screen.
-
prepare_data.py- Creating custom drowsiness dataset where user has to sit in front of webcam to capture his/her face with the background
-
finetune_model.py- Fine-tuning and training pretrained MobineNet_V2 model
-
detect_drowsiness.py- Evaluating the model performance by detecting user whether is drowsy
-
entry_point/app.py- Entry point of the desktop application to launch
-
entry_point/main.py- Implementation of window logic and model integration logic for the app
-
build.py- Run this script to use PyInstaller to compile everything to a stand-alone executable.
-
modelfolder- model with best accuracy after running
finetune_model.pyis placed over here
- model with best accuracy after running
-
soundfolder- a list of sounds or ringtones are placed here which are used to rouse user.
First, remove all .gitkeep file which are placed inside data and their children folders. Then run prepare_data.py and follow the instruction there. You may change the dataset size
from the script.
python finetune.pyNotes: The model state is checkpoint and metrics are logged under runs folder during training phase
python detect_drowsiness.py --on-gpu --model your/path/to/best/model Set --on-gpu flag if you want to evaluate model on GPU device
python build.py-
Option 1: A
distfolder is generated after runningbuild.pyor you may get it here. Insidedistfolder, go tobinfolder and locateapp.exe. Simply double click it to launch and you are good to go. You may go tosoundfolder to change your choice of sounds/ringtones. -
Option 2: On console
cd entry_point
python app.py