A deep learning project that classifies facial expressions into 8 emotion categories using Convolutional Neural Networks, trained on the FER2013+ dataset.
This project builds and compares multiple CNN architectures to recognize human facial emotions from grayscale images. The final model uses a residual CNN architecture with focal loss to handle class imbalance, achieving 82.10% test accuracy.
- Dataset: FER2013+ (Facial Expression Recognition)
- Classes (8): Anger, Contempt, Disgust, Fear, Happiness, Neutral, Sadness, Surprise
- Image size: 48x48 grayscale
- Train images: 28,386
- Test images: 7,099
The project explores multiple modeling strategies to improve accuracy and handle class imbalance:
| Model | Technique | Accuracy |
|---|---|---|
| Model 1 | Baseline CNN (3 Conv blocks + BatchNorm + Dropout) | 82.00% |
| Model 2 | CNN with Class Weights | 75.00% |
| Model 3 | Transfer Learning (MobileNetV2) | 58.00% |
| Model 4 | Ensemble (2 CNNs averaged) | 45.00% |
| Model 5 | Residual CNN + Focal Loss (Final) | 82.10% |
- Python
- TensorFlow / Keras
- NumPy, Pandas
- Matplotlib, Seaborn
- Scikit-learn
- Convolutional blocks with residual/skip connections
- Batch Normalization for stable training
- Dropout for regularization
- Focal Loss to address class imbalance
- Data augmentation (rotation, zoom, flip, shift) to improve generalization
- Resize images to 48x48
- Normalize pixel values (rescale 1./255)
- Convert to grayscale
- Apply data augmentation (train set only)
- Batch the data (batch size = 64)
- One-hot encode labels (8 classes)
Model performance was evaluated using:
- Accuracy
- Precision, Recall, F1-score (per class)
- Confusion Matrix
The final residual CNN with focal loss achieved the best overall performance, improving minority class recall while maintaining strong overall accuracy compared to the baseline and other experimental approaches.
- Further hyperparameter tuning
- Larger and more balanced dataset for minority classes (contempt, disgust)
- Experimenting with attention mechanisms
- Real-time webcam-based emotion detection
Built as part of exploring deep learning approaches to computer vision problems.