YuNet (fastforks)

YuNet (Wu et al., Machine Intelligence Research 2023): a 75k-parameter anchor-free face detector with five facial landmarks, the network behind libfacedetection and OpenCV's FaceDetectorYN (OpenCV Zoo face_detection_yunet). Depthwise-separable backbone, a tiny top-down FPN and per-cell class / objectness / box / landmark heads on the stride 8 / 16 / 32 maps. Takes the whole image at its own size (padded to multiples of 32, as upstream's WIDER FACE evaluation); vendored from libfacedetection.train's PyTorch code. The portable module() maps the image to the raw head maps (decoding and NMS stay outside).

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/ShiqiYu/libfacedetection.train at dca340aa082c.

Task: pose. Tier: stable. Outputs: keypoints, keypoint_scores, boxes, scores. Backends: portable, kernels.

Input: one RGB image and a box per person. Output: keypoints with confidence scores for every person.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
yunet-n@1 yunet_n.pth 9c7c9e14a4d6 BSD-3-Clause yes
yunet-s@1 yunet_s.pth f2688fecd5ae BSD-3-Clause yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause. Licence files: LICENSE.

Training data: WIDER FACE (32k images, 394k labelled faces) (WIDER FACE train with the SCRFD five-landmark annotations (labelv2), from scratch).

Licence evidence: https://github.com/ShiqiYu/libfacedetection.train/blob/dca340aa082c71081a68d17db8e58b33a58a914b/LICENSE

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): yunet-n 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); yunet-s 3000x4000 (0.5 GiB peak allocated, 0.6 reserved)

Speed and memory

Pose, synthetic, 1080x1920

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
yunet-n – 6.04 2.95 2.22 2.7x 1.3x 134 / 168 96 / 124 84 / 104
yunet-s – 5.55 2.67 2.00 2.8x 1.3x 118 / 148 96 / 124 84 / 104

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
yunet-n 0.49 0.61 1.91 0.48 0.23 0.07
yunet-s 0.19 0.57 0.59 0.01 0.28 0.06

torch.compile and TensorRT

model input time: portable compile TensorRT fp16 kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
yunet-n 1080x1920 2.95 ms 1.79 ms 0.794 ms (network only) 2.22 ms 8.40 s 12.1 s 96 / 124 124 / 144 84 / 104 119 / 150
yunet-s 1080x1920 2.67 ms 1.65 ms 0.680 ms (network only) 2.00 ms 7.92 s 13.4 s 96 / 124 124 / 144 84 / 104 114 / 146

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

On public datasets

Each image at its own size, score threshold 0.02 and NMS IoU 0.45 (the authors' evaluation settings), the official toolkit's AP at IoU 0.5 over the subset's faces. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 portable kernels note
yunet-n WIDER FACE val, every 4th image (807), face box AP easy / medium / hard 0.894 / 0.883 / 0.810 0.893 / 0.883 / 0.810 0.894 / 0.883 / 0.810
yunet-s WIDER FACE val, every 4th image (807), face box AP easy / medium / hard 0.885 / 0.868 / 0.764 0.885 / 0.868 / 0.764 0.885 / 0.868 / 0.764

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f104019b, 2026-11-14.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.1 and p99 <= 0.3 (absolute error of the output keypoints).

Limitations

  • module() exports the raw per-level head maps; decoding and NMS remain outside the exported graph.
  • No per-landmark confidence: keypoint_scores repeats the face score.
  • The image is not resized: faces much smaller than about 10 px are missed; large photos cost time in proportion to their pixels.

Usage

from fastforks import pose

model = pose.load("yunet-n")  # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg", boxes=[[x0, y0, x1, y1]])  # one box per person, or a fastforks.detection result
result.keypoints, result.keypoint_scores  # [P, K, 2] input pixels, [P, K]
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: yunet-n, yunet-s.

Kernels backend

pose.load("yunet-n", mode="kernels") runs our CUDA kernels (cudnn_hacc, fvm_conv, fvm_extra, fvm_mb, fvm_r3). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including fastforks/yunet