Flor commited on
Commit
5ee558c
·
verified ·
1 Parent(s): a555f57

card: update from fastforks 1cbf1671

Browse files
Files changed (1) hide show
  1. README.md +114 -0
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "keypoint-detection"
4
+ license: "bsd-3-clause"
5
+ tags:
6
+ - "pose"
7
+ - "pose-estimation"
8
+ - "human-pose-estimation"
9
+ - "keypoint-detection"
10
+ - "cuda"
11
+ - "pytorch"
12
+ - "fastforks"
13
+ - "fastforks-card"
14
+ ---
15
+ # YuNet (fastforks)
16
+
17
+ 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).
18
+
19
+ 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`.
20
+
21
+ Task: pose. Tier: stable. Outputs: `keypoints`, `keypoint_scores`, `boxes`, `scores`. Backends: `portable`, `kernels`.
22
+
23
+ Input: one RGB image and a box per person. Output: keypoints with confidence scores for every person.
24
+
25
+ ## Variants
26
+
27
+ Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/pose/models/yunet/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `yunet-n@1` | [yunet_n.pth](https://github.com/ShiqiYu/libfacedetection.train/raw/dca340aa082c71081a68d17db8e58b33a58a914b/weights/yunet_n.pth) | `9c7c9e14a4d6` | BSD-3-Clause | yes |
32
+ | `yunet-s@1` | [yunet_s.pth](https://github.com/ShiqiYu/libfacedetection.train/raw/dca340aa082c71081a68d17db8e58b33a58a914b/weights/yunet_s.pth) | `f2688fecd5ae` | BSD-3-Clause | yes |
33
+
34
+ ## Licence
35
+
36
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause. Licence files: `LICENSE`.
37
+
38
+ Training data: WIDER FACE (32k images, 394k labelled faces) (WIDER FACE train with the SCRFD five-landmark annotations (labelv2), from scratch).
39
+
40
+ Licence evidence: <https://github.com/ShiqiYu/libfacedetection.train/blob/dca340aa082c71081a68d17db8e58b33a58a914b/LICENSE>
41
+
42
+ ## Input size
43
+
44
+ any H x W >= 32, padded to a multiple of 32
45
+ 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)
46
+
47
+ ## Speed and memory
48
+
49
+ ### Pose, synthetic, 1080x1920
50
+
51
+ | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
52
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
53
+ | `yunet-n` | – | 6.04 | 2.95 | 2.22 | 2.7x | 1.3x | 134 / 168 | 96 / 124 | 84 / 104 |
54
+ | `yunet-s` | – | 5.55 | 2.67 | 2.00 | 2.8x | 1.3x | 118 / 148 | 96 / 124 | 84 / 104 |
55
+
56
+ ### Startup and first call
57
+
58
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
59
+ | --- | --- | --- | --- | --- | --- | --- |
60
+ | `yunet-n` | 0.49 | 0.61 | 1.91 | 0.48 | 0.23 | 0.07 |
61
+ | `yunet-s` | 0.19 | 0.57 | 0.59 | 0.01 | 0.28 | 0.06 |
62
+
63
+ ### torch.compile and TensorRT
64
+
65
+ | 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) |
66
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
67
+ | `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 |
68
+ | `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 |
69
+
70
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
71
+
72
+ Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (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.
73
+
74
+ ## Accuracy
75
+
76
+ ### On public datasets
77
+
78
+ 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.
79
+
80
+ | variant | dataset | original fp32 | portable | kernels | note |
81
+ |---|---|---|---|---|---|
82
+ | `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 | |
83
+ | `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 | |
84
+
85
+ Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f104019b, 2026-11-14.
86
+
87
+ ### Parity with the original code
88
+
89
+ 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`).
90
+
91
+ ## Limitations
92
+
93
+ - module() exports the raw per-level head maps; decoding and NMS remain outside the exported graph.
94
+ - No per-landmark confidence: keypoint_scores repeats the face score.
95
+ - The image is not resized: faces much smaller than about 10 px are missed; large photos cost time in proportion to their pixels.
96
+
97
+ ## Usage
98
+
99
+ ```python
100
+ from fastforks import pose
101
+
102
+ model = pose.load("yunet-n") # mode="auto": the preferred backend from recorded measurements
103
+ result = model("photo.jpg", boxes=[[x0, y0, x1, y1]]) # one box per person, or a fastforks.detection result
104
+ result.keypoints, result.keypoint_scores # [P, K, 2] input pixels, [P, K]
105
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
106
+ ```
107
+
108
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `yunet-n`, `yunet-s`.
109
+
110
+ ## Kernels backend
111
+
112
+ `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.
113
+
114
+ <!-- staged from fastforks 1cbf1671 (2026-11-15) -->