This project detects human emotions in real-time using a Convolutional Neural Network (CNN) trained on the FER-2013 dataset. The model classifies facial expressions into seven different categories and processes real-time input from a webcam using OpenCV.
The FER-2013 dataset contains labeled images of facial expressions divided into training and testing sets.
dataset/
│── train/
│ ├── happy/
│ ├── anger/
│ ├── fear/
│ ├── surprise/
│ ├── neutral/
│ ├── disgust/
│ ├── sad/
│── test/
│ ├── happy/
│ ├── anger/
│ ├── fear/
│ ├── surprise/
│ ├── neutral/
│ ├── disgust/
│ ├── sad/
Each folder contains thousands of images categorized based on emotion labels.
emotiondetection/
│── dataset/ # FER-2013 dataset
│── models/ # Saved trained model
│── src/
│ ├── train_model.py # Model training script
│ ├── test_model.py # Model testing script
│ ├── realtime_emotion.py # Real-time emotion detection
│── requirements.txt # Required dependencies
│── README.md # Project documentation
git clone https://github.com/your-username/emotion-detection-ai.git
cd emotion-detection-ai
Ensure you have Python installed, then run:
pip install -r requirements.txt
python src/train_model.py
- Trains the CNN model on the FER-2013 dataset.
- Saves the trained model in the
models/
directory.
python src/test_model.py
- Evaluates the trained model on the test dataset.
- Outputs accuracy, loss, and sample predictions.
python src/realtime_emotion.py
- Accesses the webcam using OpenCV.
- Detects and classifies facial expressions in real time.
✅ Trained on FER-2013 dataset (7 emotion classes: Happy, Sad, Anger, Fear, Disgust, Neutral, Surprise).
✅ Real-time emotion detection using OpenCV.
✅ CNN-based deep learning model with high accuracy.
✅ Fast & lightweight implementation with optimized performance.
- Python
- TensorFlow / Keras
- OpenCV
- NumPy & Pandas
- Matplotlib (for visualization)
This project is licensed under the MIT License.
Feel free to contribute by opening issues or pull requests. If you find this project helpful, give it a ⭐ on GitHub!
🚀 Happy Coding! 😊