image-classification Β· vision Β· affective computing Β· WASM Β· ~88 MB
A Vision Transformer, fine-tuned on faces, takes a single frame and scores it across
7 emotions β happy, sad, angry,
surprise, fear, disgust, neutral. Point your
camera or drop a photo; the read happens entirely in this tab.
No frame is ever uploaded or stored.
| Model | Xenova/facial_emotions_image_detection |
|---|---|
| Task / pipeline | image-classification |
| Architecture | ViT-B/16 (86M params), 224Γ224 input β a fine-tune of dima806/facial_emotions_image_detection |
| Labels | 7 emotions: angry, disgust, fear, happy, neutral, sad, surprise |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~88 MB, cached after first load |
| License | Apache-2.0 |
| Privacy | All inference is local; the camera frame / photo never leaves your device and is not stored. |
| Web APIs | WebAssembly, Web Workers, getUserMedia (camera), Canvas, FileReader β all Baseline widely available |
Use your camera, pick a sample face, or drop your own photo, then read the emotion. The bars are the softmax over all 7 classes.
π Frames are read locally and never uploaded or stored.
Sample faces are licensed portraits from Wikimedia Commons (CC-BY-SA / public domain) β see the Image credits page.
The ViT's final layer emits one raw score β a logit β per emotion. A softmax turns the 7 logits into probabilities that sum to 100%. Two numbers describe the shape of that distribution: the top-1 margin (how far the winning emotion leads the runner-up) and the normalised entropy (0 = the model is certain, 1 = it's torn between emotions). A plain smile is peaky and low-entropy; a subtle or blended expression is flat and high-entropy β which is exactly when you should NOT trust a single label. Affective reads are noisy: treat them as a soft signal, never ground truth about how someone actually feels.
| Emotion | logit | softmax |
|---|
Calibration (uncertain β β confident):
Expression is a signal most interfaces throw away, because "read the face" used to mean a camera upload to a cloud API β a privacy non-starter. Running the model locally flips that: the frame never leaves the device, so affective UX becomes something you can actually ship.
A note on ethics: facial-expression models infer a visible expression, not a person's true inner state, and they carry demographic bias. Use them for consented, low-stakes, on-device UX β never surveillance or high-stakes judgements about people.
Read one face β camera, sample, or upload β and see the 7-emotion distribution first-hand.
A reaction-capture widget: press to record your face's reaction to content, on-device.
Expression-over-time: watch your emotions move as a live graph from webcam frames.
Detect the face region first, then read its expression β a two-model pipeline.
The convenience path is two lines with Transformers.js:
import { pipeline } from "@huggingface/transformers";
const readEmotion = await pipeline(
"image-classification",
"Xenova/facial_emotions_image_detection",
); // downloads + caches ~88 MB once
const out = await readEmotion(imageOrCanvasURL, { top_k: 7 });
// β [{ label: "happy", score: 0.94 }, { label: "neutral", score: 0.03 }, β¦ ]
This page goes one level deeper for "See inside": instead of the pipeline it runs the model's own
processor then model() in a single forward pass, so it can read the raw
logits tensor and compute the softmax, entropy, and margin itself. Webcam frames are
captured to a <canvas> and classified as a data URL β nothing is uploaded.
Inference runs in a Web Worker so the camera preview never stutters.
Sample faces are real people, used under clear licenses from Wikimedia Commons (CC-BY-SA / public domain). See the Image credits page.