Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- executorch
|
| 5 |
+
- xnnpack
|
| 6 |
+
- pte
|
| 7 |
+
- on-device
|
| 8 |
+
- keypoint-detection
|
| 9 |
+
base_model:
|
| 10 |
+
- usyd-community/vitpose-plus-base
|
| 11 |
+
---
|
| 12 |
+
# ViTPose+ base β ExecuTorch (heatmap pose)
|
| 13 |
+
|
| 14 |
+
A person crop in, seventeen COCO keypoints out, from a plain ViT. This is the
|
| 15 |
+
heatmap contract β the one most pose code on the internet expects β where the
|
| 16 |
+
shelf's other pose models (RTMPose, RTMW) emit SimCC distributions instead.
|
| 17 |
+
|
| 18 |
+
```
|
| 19 |
+
pixel_values (1,3,256,192) -> heatmaps (1,17,64,48)
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
| build | file | MB | corr vs fp32 eager | Mac ms* |
|
| 23 |
+
|---|---|---|---|---|
|
| 24 |
+
| fp32 | `vitpose_plus_base_xnnpack_fp32.pte` | 501.9 | 1.000000 | 60.4 |
|
| 25 |
+
| Core ML (fp16, iOS) | `vitpose_plus_base_coreml_all.pte` | 251.6 | 0.999998 | 7.1 |
|
| 26 |
+
|
| 27 |
+
\*Mac arm64, single process, median of 10 β a reference point for relative cost,
|
| 28 |
+
not a device number. Torch eager fp32 on the same machine: 48.8 ms. XNNPACK
|
| 29 |
+
delegate coverage 65.1% (630/967 ops); the Core ML build is 100% delegated in one
|
| 30 |
+
subgraph.
|
| 31 |
+
|
| 32 |
+
## Running it
|
| 33 |
+
|
| 34 |
+
**1. The crop.** One person, RGB, divided by 255, ImageNet normalised (mean
|
| 35 |
+
.485/.456/.406, std .229/.224/.225), resized to **256 high by 192 wide**. Bring
|
| 36 |
+
your own detector β this model does not find people, it reads the pose of the one
|
| 37 |
+
you hand it.
|
| 38 |
+
|
| 39 |
+
**2. The decode.** Joint `k` is the argmax of heatmap channel `k`. With a 64Γ48
|
| 40 |
+
heatmap over a 256Γ192 crop, the scale factor is 4:
|
| 41 |
+
|
| 42 |
+
```
|
| 43 |
+
i = argmax(heatmaps[0, k]) # over the flattened 64x48 grid
|
| 44 |
+
x = (i % 48) * 4 # crop pixels
|
| 45 |
+
y = (i // 48) * 4
|
| 46 |
+
confidence = heatmaps[0, k].max()
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
Keypoints come in COCO order: nose, eyes, ears, shoulders, elbows, wrists, hips,
|
| 50 |
+
knees, ankles. Map back to the original image with the box you cropped from.
|
| 51 |
+
|
| 52 |
+
A refinement worth knowing about: the reference implementation takes a weighted
|
| 53 |
+
average around the peak instead of the raw argmax, which buys sub-pixel accuracy.
|
| 54 |
+
The recipe above is the plain one, and it is what the checks below measure.
|
| 55 |
+
|
| 56 |
+
## The expert index
|
| 57 |
+
|
| 58 |
+
The "+" checkpoint carries a mixture of experts, chosen by a `dataset_index`
|
| 59 |
+
argument β the model can speak COCO, AI Challenger, MPII, AP-10K, APT-36K or
|
| 60 |
+
whole-body. **This graph fixes it at 0, the COCO expert, and does not take the
|
| 61 |
+
index.** It selects a keypoint convention rather than a per-call option, and an
|
| 62 |
+
app that passed 5 would get a whole-body skeleton decoded as if it were COCO.
|
| 63 |
+
|
| 64 |
+
Measured on six person crops, asking each expert in turn: indices 0β3 all produce
|
| 65 |
+
anatomically ordered skeletons, index 4 five of six, and index 5 none β which is
|
| 66 |
+
what the documented order predicts, whole-body being a different convention.
|
| 67 |
+
|
| 68 |
+
## What is measured
|
| 69 |
+
|
| 70 |
+
The card's own decode, run on six person crops: **6/6 skeletons in anatomical
|
| 71 |
+
order** β nose above shoulders above hips β with every keypoint inside the crop.
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
python convert/verify_cards.py vitpose_plus_base
|
| 75 |
+
python convert/audit_int8.py vitpose_plus_base
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## Not shipped, and why
|
| 79 |
+
|
| 80 |
+
**int8 converts and is not published.** It is 141.3 MB against fp32's 501.9 MB at
|
| 81 |
+
correlation 0.999904, and it passes the anatomical check 6/6. The number that
|
| 82 |
+
decides is where the keypoints land: on ten real images, the fraction of confident
|
| 83 |
+
joints within 4 px of the fp32 build's is **1.0000 median and 0.8235 at worst** β
|
| 84 |
+
three joints out of seventeen moving further than 4 px on one image. This shelf
|
| 85 |
+
gates pose on the worst image, not the median, because a build that is perfect on
|
| 86 |
+
nine photographs and visibly wrong on the tenth is what a user finds. The bar is
|
| 87 |
+
0.90.
|
| 88 |
+
|
| 89 |
+
Correlation would have cleared it comfortably, which is the reason the bar is not
|
| 90 |
+
correlation.
|
| 91 |
+
|
| 92 |
+
- **Source**: [usyd-community/vitpose-plus-base](https://huggingface.co/usyd-community/vitpose-plus-base)
|
| 93 |
+
- **License**: Apache-2.0
|
| 94 |
+
|
| 95 |
+
torch.export -> to_edge_transform_and_lower(partitioner) -> .pte
|
| 96 |
+
(conversion scripts: [executorch-models](https://github.com/john-rocky/executorch-models))
|