- A python package/application that detects the mood of a person using a live feed from the webcam or from pictures.
- An application of this project is to detect the mood of people and suggest activities based on the prediction of the model.
- Another application of this project is to find the correlation between activities and their impact on the mood of people.
- OpenCV-python
- To read webcam inputs.
- To detect faces in the frames of videos using Haarcascade Classifier.
- To resize/convert/save/load images.
- TensorFlow
- To normalize input data.
- To define the model using
tensorflow.keras
- Convolutional Neural Network Model (CNN). - To load/save/train the model.
- Numpy for arrays (
numpy.array
). - Matplotlib for plotting training/testing accuracy and error.
Install the aforementioned dependencies using:
pip install opencv-python tensorflow numpy matplotlib
- Open MoodDetector\CONSTANTS.py and change the below values as necessary.
MOODS
: A list of the different moods the model will learn to detect/identify.TRAIN_SIZE_PER_MOOD
: The number of images per mood.EPOCHS
: The number of training loop iterations.
- Open a Terminal (Command Prompt/Bash/etc.)
- Traverse to the root directory of the project.
- Run
python App.py -t/-T/train
to collect data and train the model. - Run
python App.py -d/-D/detect
to open a webcam and detect the moods of the faces in the frame. - Press spacebar to exit.
Below is results of sample model trained on two moods: happy and sad, 250 images per mood for a total of 10 epochs.
As you can see from the above GIF, the model adequately classifies the reaction of my face into the different moods.
Moreover, two graphs Acc vs Epoch and Loss vs Epoch are displayed below.
y-axis vs x-axis | Graph |
---|---|
Accuracy vs Epoch | |
Loss vs Epoch |
- Leveraging the model into a recommendation system that knows the user's likes/dislikes and suggests activities based on his/her mood.
- Training the model using a deeper and more-sophisticated model with a much larger dataset for higher number of epochs. I don't have the compute power currently to do it.