image-classification Β· vision Β· demographic estimation Β· WASM Β· ~88 MB
A Vision Transformer, fine-tuned on faces, takes a single frame and scores it across
9 age buckets β 0-2, 3-9, 10-19,
20-29, 30-39, 40-49, 50-59,
60-69, 70+ β then folds the distribution into one expected-age number.
Drop a photo or use your camera; the read happens entirely in this tab.
No frame is ever uploaded or stored.
Be honest about what this is: a guess at apparent age from pixels. It is imperfect, it carries demographic bias (accuracy varies across skin tone, lighting, expression, and makeup), and it is not identity, verification, or a birth date. Treat it as a soft signal for low-stakes, consented UX β never a verdict about a person. The page shows the real output, right or wrong β never a canned answer.
| Model | jdp8/vit-age-classifier (ONNX of nateraw/vit-age-classifier) |
|---|---|
| Task / pipeline | image-classification |
| Architecture | ViT-B/16 (86M params), 224Γ224 input β a fine-tune for facial age |
| Labels | 9 age buckets: 0-2, 3-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, more than 70 |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~88 MB, cached after first load |
| License | Base model: nateraw/vit-age-classifier (see model card) |
| 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 estimate. The bars are the softmax across all 9 buckets, shown youngest β oldest.
π 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 bucket. A softmax turns the 9 logits into probabilities that sum to 100%. The expected age above is Ξ£ (probability Γ bucket midpoint) β it respects the whole distribution, not just the top bucket, which is why it can land between the bucket edges. Two numbers describe the shape of that distribution: the top-1 margin (how far the winning bucket leads the runner-up) and the normalised entropy (0 = certain, 1 = torn between buckets). A clear, well-lit face is peaky and low-entropy; an occluded, angled, or blended one is flat and high-entropy β exactly when you should NOT trust a single number.
| Bucket | midpoint | logit | softmax |
|---|
Calibration (uncertain β β confident):
"Estimate age from a face" used to mean uploading the photo to a cloud API β a privacy non-starter for something this sensitive. Running the model locally flips that: the frame never leaves the device, so age-aware UX becomes something you can actually ship without collecting a single image.
A note on ethics + the law: apparent-age models are imprecise and biased, and real age-verification (for restricted goods, adult content, or legal thresholds) has specific regulatory requirements this cannot meet. Use it for consented, low-stakes UX β never surveillance, discrimination, or as the sole basis for a legal age decision.
Estimate one face β camera, sample, or upload β and see the full 9-bucket distribution and expected age.
An age-gate UX concept done right: the estimate is a signal that adapts a default, never a verdict β with a confirm step.
Age-over-frames: watch the expected age wobble live from your webcam and see how unstable a single read is.
Detect the face region first (MediaPipe), then estimate age on the crop β a two-model pipeline.
The convenience path is two lines with Transformers.js:
import { pipeline } from "@huggingface/transformers";
const estimateAge = await pipeline(
"image-classification",
"jdp8/vit-age-classifier",
); // downloads + caches ~88 MB once
const out = await estimateAge(imageOrCanvasURL, { top_k: 9 });
// β [{ label: "20-29", score: 0.41 }, { label: "30-39", score: 0.22 }, β¦ ]
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, the probability-weighted expected age, and the
entropy/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.