
EmotionLens
Real-time face detection, emotion recognition, and multi-object tracking from a webcam feed — RetinaFace + a residual masking network + SORT.
Overview
Detection, classification, and context in one loop
Faces are detected in batches with RetinaFace (via the batch_face package, GPU-only), then each face is classified by a resmasking_dropout1 network — a Residual Masking Network variant adapted from phamquiluan/ResidualMaskingNetwork — trained on FER2013's 7 emotion classes: angry, disgust, fear, happy, sad, surprise, neutral.
A YOLOv5-nano pass runs alongside, filtered to person/cell-phone/laptop, to add engagement context around the faces rather than feed the emotion classifier itself.
- Angry
- Disgust
- Fear
- Happy
- Sad
- Surprise
- Neutral
SORT smooths the flicker
Per-frame emotion predictions flicker on their own, so a vendored SORT (Simple Online Real-Time Tracking) implementation tracks each face across frames and takes a majority vote over its tracked history for the final displayed label. No FPS or accuracy numbers are published for this build — 'real-time' describes the design intent, not a measured benchmark.
Method
Every frame runs through four stages: detect faces, classify each face's emotion, detect surrounding objects for context, and track faces across frames to smooth the label.
- 01RetinaFace
batched GPU face detection
- 02ResMaskingNet
7-way emotion classification
- 03SORT
track + majority-vote label
Results
Stack
Reproduce it
$ git clone https://github.com/baselhusam/EmotionLens.git$ cd EmotionLens$ pip install -r requirements.txt$ python main.py