Models · Pose estimation

YuNet

YuNet (Wu, Peng, Yu, Shenzhen University; libfacedetection.train): a tiny face detector (YuNet-n 75 k, YuNet-s 55 k parameters, OpenCV's FaceDetectorYN) that finds faces with a box and five landmarks. BSD-3-Clause code and weights.

stable Fork of ShiqiYu/libfacedetection.train@dca340a · backends: portable, kernels

Checkpoint

Paper 2023 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 2.22 ms 1080x1920, fp16
vs the faster original 2.7× original fp16: 6.04 ms
Peak memory 84 MiB original: 134 MiB
Accuracy vs original fp32 −0.000 kernels ap_easy, WIDER FACE val (0.894 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import pose

model = pose.load("yunet-n")  # kernels on a supported GPU, else portable PyTorch
result = model(image, boxes=...)
result.keypoints  # also: keypoint_scores, boxes, scores
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench yunet-n

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 1080x1920 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32not measured ––––
Original fp16torch.autocast(float16) around the call; libfacedetection.train build_yunet + YuNetPostprocessor (origin size, float32): upload, pad, network, NMSfp16 6.04–134 MiB/168 MiB0.20.97
Portable fp32fp32not measured ––––
Portablefp16 2.952.0×96 MiB/124 MiB0.60.23
Kernelsfp16 2.222.7×84 MiB/104 MiB1.90.07
Portable + torch.compile 1.793.4×124 MiB/144 MiB8 (build)–
TensorRT fp16network onlyfp16 0.7947.6×68 MiBenginenot comparable12 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-14. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-15Originalfp3234.1 1,453 MiB process–1080x1920
Portablefp1621.6 1,377 MiB processmatches1080x1920
Portablefp3224.9 1,380 MiB processmatches1080x1920
Kernelsfp16not implemented–1080x1920

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
BSD-3-Clause LICENSE
Weights
BSD-3-Clause source
Training data

Our reading of the licences, not legal advice.

Weights

yunet_n.pth 747 KB· hosted on GitHub

fastforks downloads and checks these files on first use (fastforks download yunet-n).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

WIDER FACE val

every 4th image (807), face box AP easy / medium / hard

Rundtypeap_easy ↑ap_medium ↑ap_hard ↑Δ ap_easy vs fp32 originalimagesms / image
Original fp32fp320.8940.8830.810 reference 807 –
Original fp16not measured
Portable fp32fp320.8940.8830.810 ±0.000 807 –
Portablefp160.8930.8830.810 −0.000 807 –
Kernelsfp160.8940.8830.810 −0.000 807 –

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 authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-14; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks f104019b, 2026-11-14.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. 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).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.001 not recorded
GPU default dtypes, mean |diff|≤ 0.1 0.0218
GPU default dtypes, p99 |diff|≤ 0.3 0.03939
gpu_min_score≤ 0.3 not recorded

Recorded for yunet-n on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-14, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3

Details

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

Input / output
Input: one RGB image and a box per person. Output: keypoints with confidence scores for every person.
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (552 MiB allocated)
Options
  • score_threshold=0.60.0 to 1.0· changes the output
Outputs
keypoints, keypoint_scores, boxes, scores
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
  • fvm_convfused convolutions for image classifiers
  • fvm_extrafused transformer row operations (rotary split, SwiGLU with LayerNorm)
  • fvm_mbfused MBConv blocks (MobileNet and EfficientNet families)
  • fvm_r3further fused classifier blocks
Apple (MPS)
fp32, fp16

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.
Full reference, generated from the repository

YuNet (Wu, Peng, Yu, Shenzhen University; libfacedetection.train): a tiny face detector (YuNet-n 75 k, YuNet-s 55 k parameters, OpenCV's FaceDetectorYN) that finds faces with a box and five landmarks. BSD-3-Clause code and weights.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
yunet-nsynthetic (1080x1920)original
portable
kernels
portable + torch.compile
TensorRT fp16
6.04
2.95
2.22
1.79
0.794 (network only)
134 / 168
96 / 124
84 / 104
124 / 144
119 / 150
yunet-ssynthetic (1080x1920)original
portable
kernels
portable + torch.compile
TensorRT fp16
5.55
2.67
2.00
1.65
0.680 (network only)
118 / 148
96 / 124
84 / 104
124 / 144
114 / 146
Details
  • Original code: https://github.com/ShiqiYu/libfacedetection.train at dca340aa082c
  • Code licence: BSD-3-Clause (permissive); files: LICENSE
  • Weights licence: BSD-3-Clause
  • Licence evidence: https://github.com/ShiqiYu/libfacedetection.train/blob/dca340aa082c71081a68d17db8e58b33a58a914b/LICENSE
  • Training data: WIDER FACE (32k images, 394k labelled faces) (WIDER FACE train with the SCRFD five-landmark annotations (labelv2), from scratch)
  • Options: score_threshold = 0.6 (0.0 to 1.0)
  • Kernel libraries: cudnn_hacc, fvm_conv, fvm_extra, fvm_mb, fvm_r3
  • Variants: yunet-n, yunet-s
  • Outputs: keypoints, keypoint_scores, boxes, scores; label_set: face-5
  • 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)
  • yunet-n 1080x1920, first call: portable + torch.compile 8 s (cold Inductor cache), TensorRT fp16 12 s (ONNX + engine).
  • yunet-s 1080x1920, first call: portable + torch.compile 8 s (cold Inductor cache), TensorRT fp16 13 s (ONNX + engine).
  • yunet-n original 1080x1920: torch.autocast(float16) around the call; libfacedetection.train build_yunet + YuNetPostprocessor (origin size, float32): upload, pad, network, NMS
  • yunet-s original 1080x1920: torch.autocast(float16) around the call; libfacedetection.train build_yunet + YuNetPostprocessor (origin size, float32): upload, pad, network, NMS
  • yunet-n load / first call: original 0.49 s / 0.477 s, portable 0.61 s / 0.23 s, kernels 1.91 s / 0.071 s
  • yunet-s load / first call: original 0.19 s / 0.009 s, portable 0.57 s / 0.281 s, kernels 0.59 s / 0.062 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

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.

variantdatasetoriginal fp32portableportable fp32kernelsnote
yunet-nWIDER FACE val, every 4th image (807), face box AP easy / medium / hard0.894 / 0.883 / 0.8100.893 / 0.883 / 0.8100.894 / 0.883 / 0.8100.894 / 0.883 / 0.810
yunet-sWIDER FACE val, every 4th image (807), face box AP easy / medium / hard0.885 / 0.868 / 0.7640.885 / 0.868 / 0.7640.885 / 0.868 / 0.7640.885 / 0.868 / 0.764

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

Parity

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

variantkernels error vs original, mean / p99GPU, torchkernels used
yunet-n0.0218 / 0.03939RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
yunet-s0.01636 / 0.03906RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120

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.

Example output

No example rendered for this checkpoint yet.