Skip to content

A deep learning CNN model for facial emotion recognition using EfficientNet architectures. Detects 7 emotions with 75%+ accuracy and includes real-time webcam processing and API integration.

License

Notifications You must be signed in to change notification settings

madboy482/EmotionDetectionCNN

Repository files navigation

VibeOut Emotion Recognition System

A comprehensive deep learning system for emotion recognition from facial expressions, with applications in fitness and wellness monitoring. This project uses EfficientNet architectures trained on facial expression datasets to identify seven core emotions: angry, disgust, fear, happy, neutral, sad, and surprise.

Features

  • High Accuracy Emotion Detection: Utilizes EfficientNet-B2 and EfficientNetV2-L models fine-tuned specifically for emotion recognition
  • Real-time Processing: Support for webcam input for real-time emotion analysis
  • RESTful API: FastAPI-based web service for integrating with other applications
  • Fitness Integration: Combines emotion data with vital signs (via Arduino) for comprehensive wellness monitoring
  • Enhanced Visualizations: Detailed metrics with confusion matrices and accuracy reports

Project Structure

EmotionDetectionCNN/
├── data/                      # Data handling and preprocessing
│   ├── preprocessing/         # Scripts for data preparation
│   └── FER2013/              # Emotion dataset (not included in repo)
│
├── models/                    # Model definitions
│   ├── model.py              # Original EfficientNet model
│   ├── model_v2.py           # Enhanced model with EfficientNetV2 support
│   └── trained_models/        # Pre-trained model weights (selected files only)
│
├── utils/                     # Utility functions
│   ├── data_loader.py        # Data loading and augmentation
│   ├── face_detector.py      # Face detection and preprocessing
│   └── visualization.py      # Result visualization and plotting
│
├── train.py                  # Training script
├── train_v2.py               # Enhanced training with additional features
├── evaluate.py               # Model evaluation
├── predict.py                # Prediction on images/webcam
├── app.py                    # FastAPI web application
├── requirements.txt          # Dependencies
└── README.md                 # This file

Installation

  1. Clone this repository:
git clone https://github.com/madboy482/EmotionDetectionCNN.git
cd EmotionDetectionCNN
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Download the pre-trained model (if not included in the repo) and place it in the models/trained_models/ directory.

Usage

Training a Model

python train.py --train_dir="data/processed/train" --test_dir="data/processed/test" --batch_size=32 --num_epochs=25 --model_name="efficientnet-b2"

Evaluating a Model

python evaluate.py --model_path="models/trained_models/gpu_final_model_full.pth" --train_dir="data/processed/train" --test_dir="data/processed/test" --batch_size=32 --model_name="efficientnet-b2"

Making Predictions

On an image:

python predict.py --model_path="models/trained_models/gpu_final_model_full.pth" --image="path/to/image.jpg" --model_name="efficientnet-b2"

Using webcam:

python predict.py --model_path="models/trained_models/gpu_final_model_full.pth" --model_name="efficientnet-b2"

Running the API Server

python app.py

The API will be available at http://localhost:8000

Results

The EfficientNet-B2 model achieves over 70% accuracy on the test set for the 7-class emotion recognition task.

Confusion Matrix Training History

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • FER-2013 dataset
  • EfficientNet architecture developers
  • PyTorch community

About

A deep learning CNN model for facial emotion recognition using EfficientNet architectures. Detects 7 emotions with 75%+ accuracy and includes real-time webcam processing and API integration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages