The purpose of this project was to get myself more familiar with the following packages:
- fast ai
- neptune
- captum
- shap
I used the fast ai package to train a model on the state-farm-distracted-driver-detection dataset. I achieved an accuracy of 0.933047 on the full dataset and an accuracy of 0.970033 on the dataset without category "C9 - talking to passenger". I tracked all my experiments with the neptune package package and analysed my models with the help of fast ai interpreter module, the shap package and captum package.
If you are interested in how I did that feel free to follow along.
The state-farm-distracted-driver-detection dataset contains driver images from 10 classes:
"c0": "safe driving",
"c1": "texting - right",
"c2": "talking on the phone - right",
"c3": "texting - left",
"c4": "talking on the phone - left",
"c5": "operating the radio",
"c6": "drinking",
"c7": "reaching behind",
"c8": "hair and makeup",
"c9": "talking to passenger"
- download the state-farm-distracted-driver-detection dataset
- create an account for neptune.ml -> https://docs.neptune.ml/python-api/tutorials/get-started.html
- install all packages conda env create -f driver_env.yml
Full Neptune Experiment History
If you want to follow my journey, then this part will give you all the information you need.
Start by cloning this repo folder. Then extract the state-farm-distracted-driver-detection dataset inside this folder.
Open the Prepare dataset notebook and follow along the instructions.
Note: This will create a new folder inside your project folder called "dataset". The new folder will include a rearranged copy of the state-farm-distracted-driver-detection dataset, well suited for training.
If you want to train your own models on the rearranged state-farm-distracted-driver-detection dataset, you can do so by following the Train Resnet Model For Distracted Driver Detection notebook. The notebook allows you to run one training loop. It uses neptune.ml to log all information from the current run.
If you don't want to train your own model you can also download my pre-trained weights by following this link:
Click on DDD-28 for the model trained on the full dataset or DDD-36 for the dataset trained on the dataset without c9. The weights can be downloaded under Artifacts.
If you want to get some useful statistics about your model, you can use the Evaluate Resnet Model For Distracted Driver Detection notebook. This notebook generates the confusion matrix for your model and gives you some hints on how to improve your model. For example, I found that my model from experiment DDD-28 had the most problems with the C9 category. I investigated this further, and these images are tough to distinguish from the other images. So I decided to exclude this category which led to an improvement of about 4 %.
If you want also want to remove c9 from your dataset, you can do so by running the Delete C9 from Dataset notebook. This will create a new copy of the dataset in a folder called clean_dataset which does no longer include files from the c9 class.
If you want to train a new model on the clean_dataset use the Train Resnet Model For Distracted Driver Detection notebook again.
If you want to investigate your model further with the help of the shap package and captum package you can do so by using the Inspect Best Model notebook.
I learned a lot during this project. Especially by trying to get fast ai work with the shap package and captum package. I also really learned to appreciate the neptune package package for tracking my project and statistics. That saved me a lot of time.