hrnet / README.md
Flor's picture
card: update from fastforks 1cbf1671
733b91c verified
|
Raw History Blame Contribute Delete
8.54 kB
---
library_name: "fastforks"
pipeline_tag: "keypoint-detection"
license: "apache-2.0"
tags:
- "pose"
- "pose-estimation"
- "human-pose-estimation"
- "keypoint-detection"
- "cuda"
- "pytorch"
- "fastforks"
- "fastforks-card"
---
# HRNet (fastforks)
HRNet (Sun et al. 2019): top-down 2D human pose with a high-resolution CNN that keeps a 1/4-scale branch through the whole network and repeatedly exchanges features with three coarser parallel branches; a 1 x 1 conv on the finest branch gives one heatmap per keypoint, decoded as its maximum moved a quarter heatmap pixel towards the larger neighbour. The mmpose COCO checkpoints (w32 / w48, 256 x 192 and 384 x 288) return the 17 COCO keypoints. Takes person boxes (e.g. from `fastforks.detection`) and crops each at the network size; vendored from mmpose (no mmpose / mmcv dependency). The portable `module()` maps crops to heatmaps.
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/open-mmlab/mmpose> at `5408bc76f5b8`.
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`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/pose/models/hrnet/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `hrnet-w32@1` | [hrnet-w32-coco-256x192.pth](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-256x192-81c58e40_20220909.pth) | `81c58e403a1b` | Apache-2.0 | yes |
| `hrnet-w32-384@1` | [hrnet-w32-coco-384x288.pth](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-384x288-ca5956af_20220909.pth) | `ca5956af0765` | Apache-2.0 | yes |
| `hrnet-w48@1` | [hrnet-w48-coco-256x192.pth](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth) | `0e67c6167d6a` | Apache-2.0 | yes |
| `hrnet-w48-384@1` | [hrnet-w48-coco-384x288.pth](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w48_8xb32-210e_coco-384x288-c161b7de_20220915.pth) | `c161b7defc14` | Apache-2.0 | yes |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`.
Training data: COCO 2017 (train, instance annotations), ImageNet-1k (ILSVRC 2012 classification) (COCO 2017 keypoints; the HRNet backbone was initialised from ImageNet-1k classification weights).
Licence evidence: <https://github.com/open-mmlab/mmpose/blob/5408bc76f5b848cf925a0d1857899011d8c5b497/README.md#license>
## Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `hrnet-w32` 3000x4000 (0.5 GiB peak allocated, 0.5 reserved); `hrnet-w32-384` 3000x4000 (0.7 GiB peak allocated, 0.8 reserved); `hrnet-w48` 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); `hrnet-w48-384` 3000x4000 (0.8 GiB peak allocated, 0.9 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 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `hrnet-w32` | 176 | 190 | 20.3 | 9.79 | 18.0x | 2.1x | 336 / 398 | 195 / 258 | 210 / 262 |
| `hrnet-w32-384` | 216 | 190 | 38.8 | 19.4 | 9.8x | 2.0x | 653 / 760 | 341 / 434 | 305 / 380 |
| `hrnet-w48` | 200 | 206 | 32.0 | 15.5 | 12.9x | 2.1x | 440 / 462 | 262 / 322 | 343 / 398 |
| `hrnet-w48-384` | 276 | 245 | 70.5 | 33.9 | 7.2x | 2.1x | 1014 / 1082 | 408 / 498 | 438 / 498 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `hrnet-w32` | 0.45 | 0.25 | 2.53 | 0.38 | 0.56 | 0.28 |
| `hrnet-w32-384` | 0.42 | 0.25 | 2.04 | 0.23 | 0.57 | 0.25 |
| `hrnet-w48` | 0.72 | 0.40 | 2.10 | 0.23 | 0.34 | 0.15 |
| `hrnet-w48-384` | 0.53 | 0.39 | 2.16 | 0.24 | 0.35 | 0.21 |
### 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) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `hrnet-w32` | 1080x1920 | 20.3 ms | 9.94 ms | 5.18 ms (network on person crops only) | 9.79 ms | 21.1 s | 25.5 s | 195 / 258 | 178 / 214 | 210 / 262 | 216 / 254 |
| `hrnet-w32-384` | 1080x1920 | 38.8 ms | 19.6 ms | 10.7 ms (network on person crops only) | 19.4 ms | 21.5 s | 26.3 s | 341 / 434 | 211 / 234 | 305 / 380 | 296 / 320 |
| `hrnet-w48` | 1080x1920 | 32.0 ms | 21.2 ms | 9.46 ms (network on person crops only) | 15.5 ms | 21.3 s | 26.9 s | 262 / 322 | 245 / 282 | 343 / 398 | 346 / 388 |
| `hrnet-w48-384` | 1080x1920 | 70.5 ms | 46.0 ms | 22.3 ms (network on person crops only) | 33.9 ms | 22.6 s | 28.3 s | 408 / 498 | 278 / 300 | 438 / 498 | 427 / 454 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
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.
## Accuracy
### On public datasets
Top-down on the ground-truth person boxes (non-crowd, at least one labelled keypoint), no flip test; people ranked by the mean of their 17 keypoint scores (not mmpose's rescoring and OKS-NMS), so not the papers' AP; pycocotools OKS AP; whole-body models scored on their 17 body keypoints. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
| `hrnet-w32` | COCO val2017, ground-truth person boxes, keypoint AP | 75.5 | 75.5 | 76.5 | 76.5 | |
| `hrnet-w32-384` | COCO val2017, ground-truth person boxes, keypoint AP | 76.7 | 76.7 | 77.6 | 77.7 | |
| `hrnet-w48` | COCO val2017, ground-truth person boxes, keypoint AP | 76.5 | 76.6 | 76.7 | 76.7 | |
| `hrnet-w48-384` | COCO val2017, ground-truth person boxes, keypoint AP | 77.0 | 77.0 | 77.7 | 77.6 | |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 87e1be16, 2026-11-11.
### Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 4.6e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.32 and p99 <= 4.8 (absolute error of the output `keypoints`).
## Usage
```python
from fastforks import pose
model = pose.load("hrnet-w32") # 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: `hrnet-w32`, `hrnet-w32-384`, `hrnet-w48`, `hrnet-w48-384`.
## Kernels backend
`pose.load("hrnet-w32", 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.
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->