HabitBreaker uses your webcam and a convolutional neural network to detect and stop you from preforming your bad habits.
HabitBreaker is made using transfer learning. Transfer learning utilizes a fully trained model and retrains its existing weights to classify a new set of classes. In this case we will take the popular Inception-v3 model and retraining the final layer from scratch to classify our bad habit.
First we will need to gather some data. In this case we will need some video of us preforming our bad habit and depending on the habit we will need video of us not performing our bad habit. To do so we will use open-cv to capture video and save the frames to a file that we will later use to train the model.
I ended up doing this twice, once for when I was bitting my nails and once when I was not. I record about 3 min of normal activity and 2 min of me bitting my nails. REMEMBER VARIETY GREATLY OUT WEIGHTS QUANTITY!
Now it time to train. I used tensorflow's examples library to retrain Inception-v3 final layer. Using transfer training is a huge shortcut for me. Utilizing the trained model that has extracted features form millions of images will do two things for us:
Now that we have a trained model to detect when I am bitting my nails, we can make simple predictions in real time using a webcam.
We can convert these predictions in to a dictionary that is sorted by probability.
Using the predictions we can now have a alert go off when I am bitting my nails. The easiest thing to do is have a Windows notification go off but instead I utilized myweb connected led lamp, an existing project that built. Every time I started to bite my nails my lamp would flash bright read twice reminding me to NOT.
In conclusion this model was very responsive and quick to scold me a soon as I started to bite my nails. The more variety of training data I fed the model the more accurate the model became. For example i made sure to take plenty of video of me drinking beverages so that the model would not mistake me for biting my nails. All in all this project turned out to far exceeded my expectations. The model became very accurate and quick!
The code that accompanies this post is available on Github.