Skip to content

vo-vuong/Emotion_Detection

Repository files navigation

Detect human emotions using Mediapipe, CNN

Introduction

This project is used to detect human emotions. There are 8 different types of emotions: surprise, anger, disgust, fear, sad, contempt, neutral, happy.

These are 2 major components:

  1. Face Detection: using Mediapipe library and draw bounding box.
  2. Emotion Recognition: using a CNN model built from scratch. Responsible for handling emotion recognition related functionalities from an image.

There are 2 ways to use the model: webcam(default), image.



demo

Install

To install the project, follow these steps.

  1. Clone the project from the repository:
git clone https://github.com/vo-vuong/Emotion_Detection.git
  1. Navigate to the project directory:
cd Emotion_Detection
  1. Create a virtual environment:
python -m venv .venv
source .venv/bin/activate  # For Linux/Mac
.venv\Scripts\activate  # For Windows
  1. Install the dependencies:
pip install -r requirements.txt
Inference

Run inferences on 2 different sources webcam(default), image file.

python app.py --source webcam           # webcam
                       img.jpg          # image

Project Structure

emotion_detec/
├── constants
│   └── const.py
├── data
├── outputs                             # default path of model prediction
│   ├── out_images
│   └── out_videos
├── test_images
├── trained_models                      # the folder containing pretrain model
├── utils
│   ├── data_processing_helpers.py
│   ├── download_model.py
│   ├── file_helpers.py
│   ├── matrix_helpers.py
│   └── output_helpers.py
├── app.py                              # main file to run test
├── dataset_analysis.ipynb              # dataset analysis file
├── dataset.py                          # setup dataset for train
├── detect.py
├── models.py                           # CNN model definition file
├── README.md
├── requirements.txt
└── train.py                            # training file

Additional Resources