Emotion Detection

This project is a real-time emotion detection application that uses a deep learning model to identify emotions from human faces in images. The application is built with Python and utilizes PyTorch for the model, OpenCV for image processing, and Gradio for the user interface.

Features

  • Face Detection: Automatically detects faces in an uploaded image.
  • Emotion Recognition: Classifies the emotion of each detected face into one of seven categories:
    • Angry
    • Disgust
    • Fear
    • Happy
    • Neutral
    • Sad
    • Surprise
  • Web Interface: A simple and intuitive web interface powered by Gradio to upload images and view the results.

Project Structure

β”œβ”€β”€ app.py                  # Main application file with the Gradio interface
β”œβ”€β”€ requirements.txt        # Project dependencies
β”œβ”€β”€ checkpoints/            # Contains pre-trained model weights
β”‚   β”œβ”€β”€ emotion_recognition/
β”‚   └── face_detect/
β”œβ”€β”€ dataset/                # Image data for training and testing
β”‚   └── emotions/
└── src/                    # Source code for the project
    β”œβ”€β”€ dataset.py              # Handles data loading
    β”œβ”€β”€ emotion_recognition_model.py # Emotion recognition model architecture
    β”œβ”€β”€ face_detect_model.py    # Face detection model architecture
    β”œβ”€β”€ pipeline.py             # Chains face detection and emotion recognition
    └── train.py                # Script for training the models

Installation

  1. Clone the repository:

    git clone https://huggingface.co/RashaadAhmad/Emotion-Detection
    cd emotion-detection
    
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install the dependencies:

    pip install -r requirements.txt
    

Usage

Click Here to try it out.

To start the application and its web interface, run the following command:

python app.py

This will launch a local web server. Open the provided URL in your browser to access the application. You can then upload an image to see the emotion detection in action.

Training

The model has been pre-trained, and the weights are available in the checkpoints directory. However, if you wish to retrain the model on a different dataset, you can use the train.py script:

python src/train.py

Make sure your dataset is structured correctly in the dataset directory.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support