Live Commerce Host Monitor
Internal computer vision research that replaces hours of rewatching streams with live KPIs readable second by second. Built from validated pretrained models, calibrated against bias with multimodal fusion, and designed around the privacy of the people being measured.

An internal R&D prototype that chains 4 computer vision models into one pipeline: detect faces in a live stream (a live commerce platform), recognize who they are, read 7 emotion classes, measure engagement (smiling, talking, looking at the camera), then summarize it as live KPIs and a session report, so the team sees the big picture without rewatching the video.
The problem
A single live commerce session runs for hours. How do you know when the host still has energy and where engagement drops, without rewatching the whole thing?

The ops team wanted to understand how engaged each host is with the camera and how their mood shifts across a session. Having someone rewatch hours of video and score it by hand is slow, always late and subjective. The brief: make these metrics readable second by second, automatically, while respecting the privacy of the people being measured.
Streams run for hours, too long to rewatch
A selling session lasts hours. Nobody rewatches the whole clip to assess engagement. The team needed per-second metrics that summarize instantly.
"Is the host losing energy?" Human eyes can't keep up
A host's mood and activity change constantly. Scoring by eye is subjective and patchy. We wanted a signal that can be measured as a number.
Off-the-shelf FER models are biased
Emotion models trained on standard datasets tend to read a neutral or talking face as sad or angry. Used as-is, the numbers are wrong from the start.
Knowing who is on screen means preparing photos in advance
Typical face recognition needs a set of reference photos for each person first. That is a hassle when several hosts rotate in and out. We wanted to register people live, on the spot.
Faces and emotions are sensitive biometric data
Processing face embeddings and personal emotions counts as biometric data under PDPA (Thailand's data protection law). Without designing for consent, retention and storage from day one, it becomes a liability.
The solution
Let a CV pipeline do the heavy lifting: detect, recognize, read emotion and measure engagement on every frame, then summarize it as KPIs a person can read in 3 seconds

Real-time pipeline: face → identity → emotion → engagement
Every frame runs continuously through MTCNN (finds faces) → FaceNet (identity embedding) → ViT (7 emotion classes) → MediaPipe FaceMesh (smiling, talking, looking at camera)
Readable KPIs with a rolling window
The output is Energy / Smile / Talking / Looking / Mood with 1-minute and 5-minute moving averages, so you can see live whether things are trending up or down
Click-to-enroll: register identities live
Click a face in the video, type a name, press Enter. The embedding is averaged into a file and works immediately. No reference photo set needed in advance.
Multimodal calibration to correct a single model's bias
Geometric signals from FaceMesh (smile and frown blendshapes) gate the ViT output, so neutral faces stop reading as sad and real smiles come through more clearly
Local-only and PDPA-aware by design
Face embeddings and all logs stay on the machine (gitignored) and are never sent out. Consent, retention windows and access limits were planned from the start.
How it works, in 4 steps
From a live video frame to live KPIs on the dashboard

Grab live frames
Electron embeds a real browser to open the stream, captures the screen as frames and sends them to the backend over WebSocket
Detect and recognize faces
MTCNN finds faces → FaceNet produces a 512-d embedding → cosine match against enrolled identities
Read emotion and engagement
ViT classifies 7 emotions, FaceMesh reads blendshapes as smiling, talking and looking at camera, and the two are calibrated together
Summarize KPIs and log
Combined into live KPIs in the sidebar, plus a per-frame CSV that later becomes the session report
Tech Stack & Architecture
The desktop app talks to a local Python ML backend over WebSocket. Everything is processed locally, no cloud.

FastAPI + WebSocket: low-latency two-way frame streaming, suited to continuous inference · Electron WebContentsView embeds a real browser to capture the stream and pull comments, gifts and likes in one app · Pretrained models (FaceNet / ViT / MediaPipe): building on validated models instead of training my own made the prototype faster to finish and more accurate · PyTorch + Apple MPS speeds things up on Apple Silicon, with a workaround that pins some models to the CPU to avoid an MPS bug
What I built: 8 core capabilities
The full loop, from face detection to a session report the team can review later

Face Detection & Recognition
MTCNN finds faces, FaceNet/VGGFace2 produces a 512-d embedding, then cosine matching against enrolled identities
Emotion Classification
A Vision Transformer (fine-tuned on FER+) classifies 7 emotions: angry, disgust, fear, happy, neutral, sad, surprise
Engagement Signals
MediaPipe FaceMesh 52 blendshapes + head pose → geometric smile / talking / looking / frown / blink
Click-to-Enroll
Click a face in the video, type a name, press Enter → the embedding is averaged into a file and works immediately, no reference photos needed
Live KPI Sidebar
Energy / Smile / Talking / Looking / Mood with 1-minute and 5-minute rolling windows, updated live in the app
Comment & Gift Scraper
Pulls comments, gifts, likes and viewer count from the stream (via a live-comment connector) and shows them next to the emotion metrics
Session Report
Aggregates the per-frame CSV per host per minute into behavior and emotion-mix charts with Chart.js
Two-Model Research
Compares a custom-trained YOLOv8-cls against the pretrained ViT on the same task, to answer "is training our own worth it?"
The desktop app
Open a stream in the app window and see the video, face boxes and live KPIs on one screen

Live
Stream
Hacking the problems
6 problems I had to solve myself: ML model bias, hardware quirks and real-time engineering

My own trained model read neutral faces as "angry"
The classifier fine-tuned on a public dataset had heavy class imbalance (one class had many times more images than another). On a real webcam it leaned toward the class with the most data, and neutral faces were read as angry with high confidence.
ViT still got stuck on "sad" for normal talking faces
The pretrained ViT was better, but it still stuck to negative emotions on neutral and talking faces, which pushed the mood score too negative.
Emotion labels flickered from frame to frame
Reading each frame independently made labels jump between happy, neutral and sad constantly, and face identities swapped when people moved.
Face recognition needed a photo set before it worked
Standard identification needs reference photos of each person ahead of time. That breaks down when hosts change often.
Capturing the stream and pulling comments at the same time was hard
I wanted both the live video (to read faces) and live metadata (comments, gifts, viewers) in one app, without relying on hard-to-access APIs.
The face detector was the bottleneck, and it hit an MPS bug
Face detection was the slowest step in the pipeline, and the detector also hit an Apple MPS bug (pooling needs evenly divisible sizes) that made it hang.
Deliberate design decisions
Because this touches people's biometric data, what the system does not do matters as much as what it does

This is a research prototype that captures biometric data (face embeddings) and behavioral data (emotion and attention), so it was designed around PDPA principles from the start. All data stays on the machine and is never exported. The metrics are "signals" for an overview, not fixed judgments about a person, and the docs state the models' limitations and biases clearly. A real production version would always need consent, a retention window and access limits first.
Local-only, always
Embeddings and logs stay on the machine (gitignored), never sent out
PDPA-aware
Designed for consent · retention window · access control
Signals, not verdicts
Metrics are for an overview, labeled with the models' known biases
Honest about being a prototype
Calibration is hand-tuned and not yet validated on a labeled set
Knowledge domains that got stronger
5 areas where my skills actually moved up through this project

I chained 4 models (detect → recognize → classify → mesh) to run within a single latency budget, including IoU tracking across frames and EMA smoothing. Lesson: real-time ML is a game of latency and output stability, not just a single model's accuracy number.
My own trained model had a nice top-1 score on the test set but failed in real use, because the test set inherited the class imbalance from training. Only per-class recall, a confusion matrix and live testing revealed the failure mode (neutral → angry). Lesson: one headline number can always hide a distribution problem.
A direct comparison showed that a small CNN trained on a few thousand images can't compete with a ViT pretrained on a large dataset. Lesson: training your own is only worth it when (a) the label set is non-standard, (b) there is a measurable failure mode in the real domain, or (c) you have a data flywheel feeding it. Otherwise, pretrained is the right default.
Learned emotion from ViT is blended with geometric blendshapes from FaceMesh through a gate/bias/boost mechanism to cancel out the bias a single model has. Lesson: when one model is biased, adding an independent signal is often more robust than forcing a fine-tune of the same model.
I designed a system that touches biometrics and emotion with consent, retention, local-only storage and documented model bias in mind from the start. Lesson: with sensitive personal data, ethical and legal correctness is a system requirement, not an add-on for later.
