Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- executorch
|
| 5 |
+
- xnnpack
|
| 6 |
+
- pte
|
| 7 |
+
- on-device
|
| 8 |
+
- image-segmentation
|
| 9 |
+
---
|
| 10 |
+
# u2net — ExecuTorch XNNPACK
|
| 11 |
+
|
| 12 |
+
- **Source**: xuebinqin/U-2-Net + Carve/u2net-universal weights
|
| 13 |
+
- **License**: Apache-2.0
|
| 14 |
+
- **Input**: [[1, 3, 320, 320]] — RGB, ImageNet norm, 320x320
|
| 15 |
+
- **Output**: saliency mask [1,1,320,320] 0-1 (sigmoid); min-max normalize then resize to the source image
|
| 16 |
+
|
| 17 |
+
## Variants
|
| 18 |
+
|
| 19 |
+
All variants take and return fp32 tensors — swap the `.pte` file, keep your app code.
|
| 20 |
+
|
| 21 |
+
| precision | file | size (MB) | parity vs fp32 eager (worst corr) | Mac median (ms)* |
|
| 22 |
+
|-----------|------|-----------|------------------------------------|------------------|
|
| 23 |
+
| fp32 | `u2net_xnnpack_fp32.pte` | 176.0 | 1.000000 | 56.5 |
|
| 24 |
+
| int8 | `u2net_xnnpack_int8.pte` | 44.3 | 0.980186 | 33.0 |
|
| 25 |
+
|
| 26 |
+
\*Mac arm64, single process, median of 10 — a reference point for relative cost
|
| 27 |
+
only, not a device number (torch eager fp32 on the same machine: 138.5 ms).
|
| 28 |
+
|
| 29 |
+
### Precisions that did not earn a slot
|
| 30 |
+
|
| 31 |
+
- **fp16 is not shipped**: it comes out at 100% of the fp32 file (176.0 MB vs 176.0 MB), so it buys nothing. XNNPACK serializes convolution weights as fp32 no matter what dtype the graph carries, so on a conv-heavy model fp16 saves no disk and only adds cast operations. Reach for int8 here, not fp16.
|
| 32 |
+
|
| 33 |
+
## Verification (executorch 1.4.0, torch 2.13.0)
|
| 34 |
+
|
| 35 |
+
Parity is measured against the fp32 eager model on real image input; `corr` is
|
| 36 |
+
the correlation over all elements of each output tensor.
|
| 37 |
+
|
| 38 |
+
| output | shape | max_abs_diff | corr |
|
| 39 |
+
|--------|-------|--------------|------|
|
| 40 |
+
| 0 | [1, 1, 320, 320] | 5.239e-05 | 1.000000 |
|
| 41 |
+
|
| 42 |
+
XNNPACK delegate coverage (fp32): 100.0% (477/477 ops)
|
| 43 |
+
|
| 44 |
+
## Conversion
|
| 45 |
+
|
| 46 |
+
torch.export -> to_edge_transform_and_lower(XnnpackPartitioner) -> .pte
|
| 47 |
+
(conversion scripts: [executorch-models](https://github.com/john-rocky/executorch-models))
|