ht167/emotion-sensor-2.0
0
๐ญ Emotion Detection 2.0
Real-time facial emotion detection web application powered by a 4-block CNN trained on FER2013.
How It Works
- Browser captures webcam frames via
getUserMedia() - Frames are sent as base64 JPEG over WebSocket to the server
- Haar Cascade detects face bounding boxes
- Each face is preprocessed: crop โ grayscale โ 48ร48 โ normalize
- CNN (4 conv blocks + softmax) predicts emotion probabilities
- Results are sent back and rendered as live overlays
Emotions Detected
File Structure
โโโ Dockerfile # Docker build config for HF Spaces
โโโ app.py # FastAPI web server (entry point)
โโโ model_structure.py # CNN architecture definition
โโโ processing.py # Face detection & preprocessing
โโโ emotion_model.h5 # Pre-trained model weights (~12 MB)
โโโ requirements.txt # Python dependencies
โโโ templates/
โ โโโ index.html # Web UI template
โโโ static/
โโโ css/
โ โโโ style.css # Dark glassmorphism theme
โโโ js/
โโโ app.js # Frontend logic (WebSocket + Canvas)Requirements
- Python 3.9+
- Webcam
- ~500 MB RAM
- No GPU required (CPU-optimized with
tensorflow-cpu)
Privacy
All processing is performed locally. No images or data leave your machine.
