VALENCE

VALENCE
Real-Time Facial Emotion Detection AI Platform
Editorial Case Review
VALENCE is an end-to-end affective computing platform that classifies human facial expressions into 7 universal emotion categories in real time. The system is powered by a custom ResNet-18 backbone augmented with a CBAM attention module, trained on FER-2013 and AffectNet using Multi-class Focal Loss. The backend is FastAPI with asyncio.to_thread CPU offloading and a bounded WebSocket queue. The frontend features a live canvas webcam overlay, multi-face image analyzer, video timeline scrubber, and real-time dashboard.
Core Capabilities
Live webcam emotion tracking over WebSockets with EMA temporal smoothing
Multi-face detection on images up to 4K with per-face probability breakdowns
Frame-by-frame video analysis generating emotion arc timelines
Custom ResNet-18 + CBAM attention model achieving 67.6% accuracy on 7 emotions
30% structured pruning & calibrated logit adjustment for CPU-optimized deployment
Real-time system health dashboard tracking model status and session analytics
Engineering Case Study
Achieving sub-60ms real-time inference on CPU, handling severe class imbalance (Disgust had 16× fewer samples than Happy), and preventing WebSocket frame queue buildup during sustained live streaming.
Applied 30% L1 structured pruning and pinned PyTorch to 2 CPU threads reducing latency from 2,580ms to ~16ms. Solved class imbalance with Multi-class Focal Loss (γ=2.0), inverse-frequency class weights, and logit prior adjustment (τ=0.30). Eliminated queue buildup using asyncio.Queue(maxsize=1) to auto-drop stale frames.
Development Journey & Milestones
Architecture & System Design
Structured the schema for VALENCE, defining state management patterns and API route handlers.
Full-Stack Implementation
Engineered core features using PyTorch, FastAPI, OpenCV (YuNet) with component modularity.
Performance & Optimization
Applied server-side rendering, debounced event flows, and asset compression for top Lighthouse scores.
Deployment & CI/CD Telemetry
Deployed live production build with continuous integration and automated telemetry tracking.
Key Specifications
Built With
Product Performance
Local Setup Commands
git clone https://github.com/Rameshwar-bhagwat10/Emotion-Detection-AI.git
cd valence
npm install
npm run devInterface Gallery
