At a glance

Model ID
opencv/face_detection_yunet
ONNX File
face_detection_yunet_2023mar.onnx
Task / Modality
face-detection · vision
Architecture
YuNet Anchor-Free Multi-Stride CNN (strides 8 / 16 / 32)
Runtime & Backend
onnxruntime-web@1.21.0 · CPU WASM (universal, no WebGPU needed)
Precision & Size
fp32 · 0.23 MB (232,589 B)
Input Tensor
input [1, 3, padH, padW] float32 BGR 0..255
License
MIT (Copyright © 2020 Shiqi Yu · OpenCV Zoo)
Critical BGR 0..255 contract: Unlike ImageNet/PyTorch models that expect normalized RGB in [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:

OpenCV YuNet (fp32)
0.23 MB
eDifFIQA Face Quality (fp32)
7.30 MB
Typical RF-DETR / ViT Detector (q8)
~29 MB

Run YuNet locally in your browser

Download or auto-initialise OpenCV YuNet (0.23 MB) above to run real face & 5-landmark detection.

Photo: loading… Tensor: –
Dots: Right eye · Left eye · Nose tip · Right mouth · Left mouth · Amber line = eye roll axis

Live Detection & Head-Roll Telemetry

Faces found –
Top score –
ORT Infer –
Total pass –
Backend WASM fp32
Active face –
Head-roll angle (eye line) 0.0°

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.

Detected faces and 5-landmark geometry from the live ONNX run
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

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

References