This project classifies the emotion on a person’s face from a live video feed: angry, happy, neutral, sad or surprised.

How I built it

Data

The model is trained on FER2013: about 35,900 grayscale face images of 48×48 pixels, with separate training and test sets. I used five of the expression classes.

Model

Instead of training a network from zero, I used transfer learning: MobileNetV2 as the base model with new fully connected layers on top for the five classes. MobileNetV2 is small and fast, which matters when the model has to run on every webcam frame.

Real-time inference

OpenCV reads the webcam, finds faces in each frame with a Haar cascade classifier, crops each face, resizes it to 224×224 for the model, and writes the predicted emotion on the frame. The trained model ships as an .h5 file, so the app starts without retraining.