face-detection Β· vision Β· MediaPipe Β· ~230 KB
MediaPipe's FaceDetector (BlazeFace short-range) finds faces in an image or video and returns, for
each one, a bounding box, 6 keypoints (eyes, nose tip, mouth,
ears) and a confidence score. It's a tiny .tflite model β about
230 KB β that runs on-device via WebAssembly (with a GPU delegate when available). Drop a
photo or turn on your webcam.
| Model | MediaPipe FaceDetector β BlazeFace short-range (Google) |
|---|---|
| Runtime | MediaPipe Tasks Vision (@mediapipe/tasks-vision) β .task bundle |
| Output | Per face: bounding box (pixels), 6 keypoints (normalized), confidence score |
| Range | Short-range β best for faces within ~2 m of the camera; many faces at once |
| Delegate | GPU when a WebGPU/WebGL adapter exists, otherwise CPU (XNNPACK) |
| Download | ~230 KB .tflite file, cached by the browser after first load |
| License | Apache-2.0 (Google MediaPipe) |
| Web APIs | WebAssembly, Canvas, getUserMedia β all Baseline widely available |
Pick a sample, drop your own photo, or use your webcam. Every detected face is boxed with its 6 keypoints and confidence drawn straight on the canvas.
Each detection is a pixel-space bounding box (originX, originY, width, height), six
normalized keypoints, and a confidence score. Below is the raw box + score for every face found β
exactly what the model returned.
| # | x | y | w | h | score |
|---|
A face box is the first step in almost every camera feature. FaceDetector is small and fast enough to run every frame on a phone, so "is there a face, and where?" becomes a free local primitive β no cloud vision API, no per-call cost, nothing leaving the device.
Box the faces in a sample photo and read every bounding box and score β feel what the model returns.
A privacy blur: redact every face in a photo on-device, then export the anonymised image.
A face counter / photobooth β count how many faces are in a crowd, live.
Detect then mesh: FaceDetector boxes the faces, FaceLandmarker adds the 478-point mesh.
MediaPipe Tasks loads the model asset (a .tflite bundle for this detector) and gives you a detector you call per image or per video frame:
import { FilesetResolver, FaceDetector } from "@mediapipe/tasks-vision";
const vision = await FilesetResolver.forVisionTasks(".../wasm");
const detector = await FaceDetector.createFromOptions(vision, {
baseOptions: {
modelAssetPath: ".../blaze_face_short_range.tflite", // ~230 KB
delegate: "GPU", // or "CPU"
},
runningMode: "IMAGE", // or "VIDEO"
});
const result = detector.detect(imageElement);
// result.detections β [ {
// boundingBox: { originX, originY, width, height }, // pixels
// keypoints: [ {x, y} Γ 6 ], // normalized 0β1
// categories: [ { score } ],
// }, β¦ ]
This page loads the model through the showcase's shared auto-init loader and draws the boxes on a canvas at the image's natural resolution; for the webcam it switches the task to VIDEO mode and calls detectForVideo each frame.