Models · Pose estimation

RetinaFace

RetinaFace (ResNet-50, MobileNet-0.25; biubug6 / facexlib): finds faces with a box and five landmarks (eyes, nose, mouth corners); the detector CodeFormer and GFPGAN use for face restoration. MIT.

stable Fork of xinntao/facexlib@260620a · backends: portable, kernels

Checkpoint

Paper 2019 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 11.7 ms 1080x1920, fp16
vs the faster original 6.8× original fp16: 79.4 ms
Peak memory 379 MiB original: 371 MiB
Accuracy vs original fp32 ±0.000 kernels ap_easy, WIDER FACE val (0.954 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("retinaface-resnet50")  # 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 retinaface-resnet50

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 fp32facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decodefp32 81.00.98×545 MiB/648 MiB1.90.48
Original fp16torch.autocast(float16) around the call; facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decodefp16 79.4–371 MiB/490 MiB0.40.31
Portable fp32fp32not measured ––––
Portablefp16 24.33.3×405 MiB/504 MiB0.70.11
Kernelsfp16 11.76.8×379 MiB/464 MiB1.60.10
Portable + torch.compile 16.54.8×374 MiB/444 MiB10 (build)–
TensorRT fp16network onlyfp16 9.108.7×242 MiBenginenot comparable20 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13. 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-14Originalfp32256 1,871 MiB process–1080x1920
Portablefp16150 1,913 MiB processmatches1080x1920
Portablefp32210 1,879 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
MIT LICENSE
Weights
MIT source
Training data

Our reading of the licences, not legal advice.

Weights

detection_Resnet50_Final.pth 109 MB· hosted on GitHub

fastforks downloads and checks these files on first use (fastforks download retinaface-resnet50).

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.9540.9390.841 reference 807 –
Original fp16not measured
Portable fp32fp320.9540.9400.841 ±0.000 807 21.8
Portablefp160.9540.9390.840 ±0.000 807 –
Kernelsfp160.9540.9390.840 ±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-16; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 3bf0bac7, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 68b2f345, 2026-11-16.

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.016 and p99 <= 0.04 (absolute error of the output keypoints).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.001 not recorded
GPU default dtypes, mean |diff|≤ 0.016 0.00589
GPU default dtypes, p99 |diff|≤ 0.04 0.01506
gpu_min_score≤ 0.3 not recorded

Recorded for retinaface-resnet50 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3

Details

RetinaFace (Deng et al., CVPR 2020) in the facexlib / Pytorch_Retinaface version: single-stage face detection with five facial landmarks (eyes, nose, mouth corners), the detector of the CodeFormer / GFPGAN face restoration pipelines. A ResNet-50 or MobileNet-0.25 backbone, an FPN, SSH context modules and per-anchor face, box and landmark heads on the stride 8 / 16 / 32 maps. Takes the whole image at its own size (no resize, as facexlib's default `use_origin_size=True`); vendored from facexlib 0.3.0 (no facexlib / torchvision dependency). The portable `module()` maps the image to the raw head maps (anchor 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 (1,603 MiB allocated)
Options
  • score_threshold=0.80.0 to 1.0· changes the output
Outputs
keypoints, keypoint_scores, boxes, scores
Checkpoint
backbone="resnet50"
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; anchor decoding and NMS remain outside the exported graph.
  • No per-landmark confidence: keypoint_scores repeats the face score.
  • The image is not resized: large photos cost time and memory in proportion to their pixels; downscale them first for big faces.
Full reference, generated from the repository

RetinaFace (ResNet-50, MobileNet-0.25; biubug6 / facexlib): finds faces with a box and five landmarks (eyes, nose, mouth corners); the detector CodeFormer and GFPGAN use for face restoration. MIT.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
retinaface-resnet50synthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
81.0
79.4
24.3
11.7
16.5
9.10 (network only)
545 / 648
371 / 490
405 / 504
379 / 464
374 / 444
451 / 462
retinaface-mobilenet0.25synthetic (1080x1920)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
75.9
77.4
3.44
2.74
2.16
0.982 (network only)
110 / 128
87 / 110
86 / 108
105 / 128
125 / 148
133 / 144
Details
  • Original code: https://github.com/xinntao/facexlib at 260620ae9399
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT
  • Licence evidence: https://github.com/xinntao/facexlib/blob/260620ae93990a300f4b16448df9bb459f1caba9/README.md
  • Training data: WIDER FACE (32k images, 394k labelled faces) (WIDER FACE train with the RetinaFace five-landmark annotations; the ResNet-50 backbone starts from ImageNet classification weights)
  • Options: score_threshold = 0.8 (0.0 to 1.0)
  • Kernel libraries: cudnn_hacc, fvm_conv, fvm_extra, fvm_mb, fvm_r3
  • Variants: retinaface-resnet50, retinaface-mobilenet0.25
  • 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): retinaface-resnet50 3000x4000 (1.6 GiB peak allocated, 1.8 reserved); retinaface-mobilenet0.25 3000x4000 (0.5 GiB peak allocated, 0.5 reserved)
  • retinaface-resnet50 1080x1920, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).
  • retinaface-mobilenet0.25 1080x1920, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 54 s (ONNX + engine).
  • retinaface-resnet50 original (fp32) 1080x1920: facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decode
  • retinaface-resnet50 original 1080x1920: torch.autocast(float16) around the call; facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decode
  • retinaface-mobilenet0.25 original (fp32) 1080x1920: facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decode
  • retinaface-mobilenet0.25 original 1080x1920: torch.autocast(float16) around the call; facexlib 0.3.0 detect_faces (use_origin_size, float32): preprocessing, network, NMS, decode
  • retinaface-resnet50 load / first call: original 0.43 s / 0.306 s, portable 0.71 s / 0.111 s, kernels 1.55 s / 0.104 s
  • retinaface-mobilenet0.25 load / first call: original 0.13 s / 1.369 s, portable 0.71 s / 0.677 s, kernels 1.49 s / 0.064 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
retinaface-resnet50WIDER FACE val, every 4th image (807), face box AP easy / medium / hard0.954 / 0.939 / 0.8410.954 / 0.939 / 0.8400.954 / 0.940 / 0.8410.954 / 0.939 / 0.840
retinaface-mobilenet0.25WIDER FACE val, every 4th image (807), face box AP easy / medium / hard0.905 / 0.882 / 0.7410.905 / 0.882 / 0.741

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 68b2f345, 2026-11-16; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 3bf0bac7, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 68b2f345, 2026-11-16.

Parity

CPU, float32: max |diff| <= 0.001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.016 and p99 <= 0.04 (absolute error of the output keypoints).

variantkernels error vs original, mean / p99GPU, torchkernels used
retinaface-resnet500.00589 / 0.01506RTX 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
retinaface-mobilenet0.250.01056 / 0.02666RTX 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; anchor decoding and NMS remain outside the exported graph.
  • No per-landmark confidence: keypoint_scores repeats the face score.
  • The image is not resized: large photos cost time and memory in proportion to their pixels; downscale them first for big faces.

Example output

No example rendered for this checkpoint yet.