Skip to content

A python program that detects the mood of the person in a webcam live feed using Convolutional Neural Networks.

License

Notifications You must be signed in to change notification settings

shreeviknesh/MoodDetector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mood Detector

  • 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.

Contents

Dependencies

  1. OpenCV-python
    • To read webcam inputs.
    • To detect faces in the frames of videos using Haarcascade Classifier.
    • To resize/convert/save/load images.
  2. TensorFlow
    • To normalize input data.
    • To define the model using tensorflow.keras - Convolutional Neural Network Model (CNN).
    • To load/save/train the model.
  3. Numpy for arrays (numpy.array).
  4. Matplotlib for plotting training/testing accuracy and error.

Installing Dependencies

Install the aforementioned dependencies using: pip install opencv-python tensorflow numpy matplotlib

Usage

  1. 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.
  2. Open a Terminal (Command Prompt/Bash/etc.)
  3. Traverse to the root directory of the project.
  4. Run python App.py -t/-T/train to collect data and train the model.
  5. Run python App.py -d/-D/detect to open a webcam and detect the moods of the faces in the frame.
  6. Press spacebar to exit.

Sample

Below is results of sample model trained on two moods: happy and sad, 250 images per mood for a total of 10 epochs. Detection Sample

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 Accuracy vs Epoch
Loss vs Epoch Loss vs Epoch

Future Work

  • 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.

About

A python program that detects the mood of the person in a webcam live feed using Convolutional Neural Networks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages