This project implements a real-time emotion detection system using a deep learning model trained on the AffectNet dataset. The model is capable of recognizing eight emotions: Angry, Disgust, Fear, Happiness, Neutral, Sadness, Surprise, and Contempt.
- Real-time facial emotion recognition using OpenCV.
- Deep learning model trained on the AffectNet dataset.
- Supports multiple face detection in a single frame.
- Pretrained model (
.h5format) for quick deployment.
This model is trained using the AffectNet dataset, a large-scale facial expression dataset containing annotated images of different human emotions. The dataset was preprocessed by resizing images to 96x96 pixels and normalizing pixel values.
Dataset link: AffectNet on Kaggle
To set up the project, first install the required dependencies:
pip install -r requirements.txtTo train the model from scratch, run the following script:
python train.pyThis will:
- Load and preprocess images from the AffectNet dataset.
- Train a deep learning model with Convolutional Neural Networks (CNNs).
- Save the trained model as
emotiondetector.h5.
To run real-time emotion detection using a webcam, execute:
python main.pyThe model consists of multiple convolutional layers, batch normalization, dropout, and fully connected layers. It uses the Softmax activation function in the final layer to classify emotions.
The following libraries are required for the project:
- TensorFlow/Keras
- OpenCV
- NumPy
- Pandas
- Scikit-learn
This project was developed as part of an emotion recognition system using deep learning techniques.
tensorflow
keras
opencv-python
numpy
pandas
scikit-learn
matplotlib
tqdm
Ensure you have Python 3.7+ installed before installing dependencies.