At a glance
[0, 1], OpenCV YuNet expects BGR channel order
in unnormalized 0..255 float32 with input height and width
padded to multiples of 32. Feeding RGB 0..1 silently collapses detection scores.
The 230 KB Footprint Advantage
YuNet downloads smaller than a single high-resolution hero JPEG, yet predicts both tight face bounding boxes and 5-point eye/nose/mouth geometry in one forward pass:
Run YuNet locally in your browser
Download or auto-initialise OpenCV YuNet (0.23 MB) above to run real face & 5-landmark detection.
Live Detection & Head-Roll Telemetry
Click any detected face on the canvas to inspect its inter-ocular distance and 5 landmarks.
See inside YuNet: 12 output heads & 5-landmark decoding
YuNet runs an ultra-compact feature pyramid at three spatial strides —
stride 8 (fine grid for small/distant faces), stride 16 (medium
faces), and stride 32 (large close-ups). Each stride emits 4 tensors
(cls, obj, bbox, kps = 12 outputs
total). Every grid cell scores sqrt(clamp(cls) × clamp(obj)), decodes its
box and 5 landmarks relative to cell coordinates, and suppresses duplicates with greedy
IoU NMS (0.3) — all inside a Web Worker.
| Face | Confidence | Stride | Box (x, y, w × h) | Eye Span | Head Roll | Pose |
|---|---|---|---|---|---|---|
| Run detection above to inspect decoded faces. | ||||||
Show the code — rgbaToBgrFloat32CHW() BGR 0..255 white-flattened preprocessing
Show the code — runDetect() ORT-Web 1.21.0 CPU WASM execution & tensor disposal
Why a 230 KB MIT face detector matters on the web
- Instant zero-server privacy redaction: Blur or pixelate every bystander face client-side before photos ever leave the device, with a model smaller than a web font.
-
5-point biometric alignment: Eye coordinates let you rotate and center
faces to exact passport/KYC geometry before handing
112×112crops to downstream recognition or quality models. - 28+ fps on CPU alone: Runs smoothly on laptops and phones without WebGPU flags, enabling AR overlays, framing guides, and head-tilt feedback everywhere.
Explore the YuNet use-case ladder
How the API works
import * as ort from "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.21.0/dist/ort.wasm.min.mjs";
const session = await ort.InferenceSession.create(
"https://huggingface.co/opencv/face_detection_yunet/resolve/main/face_detection_yunet_2023mar.onnx",
{ executionProviders: ["wasm"] },
);
// Feed [1, 3, padH, padW] float32 in BGR channel order, unnormalized 0..255!
const input = new ort.Tensor("float32", bgrFloat32CHW, [1, 3, padH, padW]);
const outputs = await session.run({ input });
// Decode cls_{8,16,32}, obj_{8,16,32}, bbox_{8,16,32}, kps_{8,16,32} + greedy IoU NMS (0.3).