← All models

image-classification Β· vision Β· demographic estimation Β· WASM Β· ~88 MB

Age estimation β€” a soft signal, read on your device

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.

At a glance

Modeljdp8/vit-age-classifier (ONNX of nateraw/vit-age-classifier)
Task / pipelineimage-classification
ArchitectureViT-B/16 (86M params), 224Γ—224 input β€” a fine-tune for facial age
Labels9 age buckets: 0-2, 3-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, more than 70
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~88 MB, cached after first load
LicenseBase model: nateraw/vit-age-classifier (see model card)
PrivacyAll inference is local; the camera frame / photo never leaves your device and is not stored.
Web APIsWebAssembly, Web Workers, getUserMedia (camera), Canvas, FileReader β€” all Baseline widely available

Run it

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.

Selected face to estimate

πŸ”’ Frames are read locally and never uploaded or stored.

Drop a face photo, or click to choose
Sample face A Sample face B Sample face C, wearing sunglasses Sample face D, wearing glasses

Sample faces are licensed portraits from Wikimedia Commons (CC-BY-SA / public domain) β€” see the Image credits page.

See inside

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.

Estimate an age to see the raw numbers.

Why it matters

"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.

Use cases

Basics

Estimate one face β€” camera, sample, or upload β€” and see the full 9-bucket distribution and expected age.

Practical

An age-gate UX concept done right: the estimate is a signal that adapts a default, never a verdict β€” with a confirm step.

Wild

Age-over-frames: watch the expected age wobble live from your webcam and see how unstable a single read is.

Multi-model

Detect the face region first (MediaPipe), then estimate age on the crop β€” a two-model pipeline.

How the API works

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.

References

Sample faces are real people, used under clear licenses from Wikimedia Commons (CC-BY-SA / public domain). See the Image credits page.