Facial Emotion Recognition
A passion project in computer vision: a CNN that sorts face images into seven emotions, built in a team of three.
- Role
- Team of 3 with Lamya Adenwala and Keenan Pereira. I wrote the preprocessing and evaluation scripts, debugged the code, and drafted the methodology and results.
- Status
- SHIPPED
- Stack
- Python, Keras, TensorFlow, OpenCV, Matplotlib
The problem
How well can a straightforward CNN tell seven emotions apart from a single grayscale face, and where does it stop improving?
Computer vision is the part of AI I find most exciting, and this was my way into it: classify a facial expression from a single image, even though expressions are subtle and vary with pose, lighting and the person.
Constraints
- About 28,700 training and 7,200 test face images in seven classes: angry, disgust, fear, happy, neutral, sad and surprise.
- Team of three. My part: the preprocessing and evaluation scripts, debugging, and the methodology and results write-up.
The system
- 01Converted every image to grayscale, resized it, scaled pixels to the 0–1 range, and augmented with flips and rotations.
- 02Built a Keras CNN of convolution, pooling and dense layers ending in a seven-way softmax.
- 03Trained the same model for 5, 70 and 200 epochs to see where learning stops.
Result
- Validation accuracy about 62%: 61.9% after 5 epochs and 62.0% after 70.
- At 200 epochs training accuracy passed 81% while validation did not follow, a clear sign of overfitting.
- Class imbalance was the main challenge: far more happy faces than any other emotion.
Limitations
- Validation accuracy stalled around 62% while training accuracy kept rising: the model learned the training faces rather than the emotions.
- With far more happy faces than anything else, the rarer emotions get less to learn from.
What I'd try next
- Early stopping and learning-rate schedules instead of fixed epoch counts.
- Transfer learning from pre-trained models such as VGG16, ResNet50 or MobileNet.
- Class weighting and stronger augmentation for the rarer emotions.
- Testing on other datasets, such as AffectNet.
Want to talk through how I built this?
I'm happy to walk through the decisions, what failed and what I'd change.