Add ExecuTorch WebGPU program for sam2-hiera-tiny
Browse files
NOTICE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
This repository contains a modified version of facebook/sam2-hiera-tiny.
|
| 2 |
|
| 3 |
Modifications by Meta Platforms, Inc.: conversion to the ExecuTorch program format (.pte) for the
|
| 4 |
-
ExecuTorch WebGPU backend
|
| 5 |
|
| 6 |
The original work and these modifications are distributed under the license in LICENSE.
|
|
|
|
| 1 |
This repository contains a modified version of facebook/sam2-hiera-tiny.
|
| 2 |
|
| 3 |
Modifications by Meta Platforms, Inc.: conversion to the ExecuTorch program format (.pte) for the
|
| 4 |
+
ExecuTorch WebGPU backend.
|
| 5 |
|
| 6 |
The original work and these modifications are distributed under the license in LICENSE.
|
README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- facebook/sam2-hiera-tiny
|
| 5 |
-
base_model_relation: quantized
|
| 6 |
library_name: executorch
|
| 7 |
pipeline_tag: mask-generation
|
|
|
|
| 8 |
tags:
|
| 9 |
- executorch
|
| 10 |
- webgpu
|
|
@@ -15,14 +15,41 @@ tags:
|
|
| 15 |
|
| 16 |
This repository contains an [ExecuTorch](https://github.com/pytorch/executorch) conversion of
|
| 17 |
[facebook/sam2-hiera-tiny](https://huggingface.co/facebook/sam2-hiera-tiny) for the ExecuTorch **WebGPU** backend, so the model runs entirely in a web browser on
|
| 18 |
-
the visitor's GPU. It powers the corresponding demo in the
|
| 19 |
-
ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)).
|
| 20 |
|
| 21 |
- **Base model:** [facebook/sam2-hiera-tiny](https://huggingface.co/facebook/sam2-hiera-tiny)
|
| 22 |
- **Format:** ExecuTorch `.pte` programs delegated to the WebGPU backend
|
| 23 |
- **Quantization:** fp32 (as exported)
|
| 24 |
- **Total size:** 149.3 MB
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
## Files
|
| 27 |
|
| 28 |
| File | Size | SHA-256 |
|
|
@@ -42,18 +69,35 @@ Full checksums are in `manifest.json`. The playground verifies them after downlo
|
|
| 42 |
|
| 43 |
## Running it
|
| 44 |
|
| 45 |
-
These programs
|
| 46 |
-
([backends/webgpu](https://github.com/pytorch/executorch/tree/main/backends/webgpu))
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
## Provenance
|
| 51 |
|
| 52 |
- Converted from the upstream checkpoint by the ExecuTorch team with the WebGPU export path.
|
| 53 |
- A reproducible export recipe will be published alongside the open-source ExecuTorch WebGPU runtime.
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
## License
|
| 56 |
|
| 57 |
This is a derivative of the upstream model and is distributed under the same terms
|
| 58 |
(`apache-2.0`); see `LICENSE`.
|
| 59 |
-
Modifications (conversion to the ExecuTorch format
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- facebook/sam2-hiera-tiny
|
|
|
|
| 5 |
library_name: executorch
|
| 6 |
pipeline_tag: mask-generation
|
| 7 |
+
inference: false
|
| 8 |
tags:
|
| 9 |
- executorch
|
| 10 |
- webgpu
|
|
|
|
| 15 |
|
| 16 |
This repository contains an [ExecuTorch](https://github.com/pytorch/executorch) conversion of
|
| 17 |
[facebook/sam2-hiera-tiny](https://huggingface.co/facebook/sam2-hiera-tiny) for the ExecuTorch **WebGPU** backend, so the model runs entirely in a web browser on
|
| 18 |
+
the visitor's GPU. It powers the corresponding demo in the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)).
|
|
|
|
| 19 |
|
| 20 |
- **Base model:** [facebook/sam2-hiera-tiny](https://huggingface.co/facebook/sam2-hiera-tiny)
|
| 21 |
- **Format:** ExecuTorch `.pte` programs delegated to the WebGPU backend
|
| 22 |
- **Quantization:** fp32 (as exported)
|
| 23 |
- **Total size:** 149.3 MB
|
| 24 |
|
| 25 |
+
## About the original model
|
| 26 |
+
|
| 27 |
+
The tiny Hiera variant of SAM 2, a foundation model for promptable visual segmentation in images and videos.
|
| 28 |
+
|
| 29 |
+
- **Developed by:** Meta FAIR
|
| 30 |
+
- **Paper:** [SAM 2: Segment Anything in Images and Videos](https://arxiv.org/abs/2408.00714)
|
| 31 |
+
- 38.9M parameters
|
| 32 |
+
- Segments any object from point or box prompts
|
| 33 |
+
|
| 34 |
+
For training data, evaluation results and full details, see the original model card: [facebook/sam2-hiera-tiny](https://huggingface.co/facebook/sam2-hiera-tiny).
|
| 35 |
+
|
| 36 |
+
## Intended use and limitations
|
| 37 |
+
|
| 38 |
+
Interactive segmentation of objects in images from clicks or boxes.
|
| 39 |
+
|
| 40 |
+
This conversion covers single-image segmentation only (no video memory). Masks can be imprecise on thin structures, low-contrast boundaries or heavily occluded objects.
|
| 41 |
+
|
| 42 |
+
## What changed in this conversion
|
| 43 |
+
|
| 44 |
+
- Image encoder and mask decoder exported as separate programs
|
| 45 |
+
- Fixed 512x512 input (upstream: 1024x1024)
|
| 46 |
+
- Prompt embeddings are precomputed and shipped as `prompt_*.bin` files
|
| 47 |
+
|
| 48 |
+
## Inputs and outputs
|
| 49 |
+
|
| 50 |
+
- `sam2_encoder.pte`: one 512x512 RGB image, ImageNet-normalized (mean 0.485/0.456/0.406, std 0.229/0.224/0.225), to image embeddings
|
| 51 |
+
- `sam2_decoder.pte`: image embeddings plus prompt tokens built from `prompt_*.bin`, to mask logits
|
| 52 |
+
|
| 53 |
## Files
|
| 54 |
|
| 55 |
| File | Size | SHA-256 |
|
|
|
|
| 69 |
|
| 70 |
## Running it
|
| 71 |
|
| 72 |
+
These programs were exported with the ExecuTorch WebGPU backend
|
| 73 |
+
([backends/webgpu](https://github.com/pytorch/executorch/tree/main/backends/webgpu)) and validated with the
|
| 74 |
+
WebAssembly runtime build used by the ExecuTorch WebGPU Playground (launching soon on [executorch.ai](https://executorch.ai)). That runtime build is not published yet; until it is,
|
| 75 |
+
the playground is the supported way to run them. It downloads these files once, caches them in the browser,
|
| 76 |
+
and runs everything locally.
|
| 77 |
+
|
| 78 |
+
Requirements: a browser with WebGPU enabled.
|
| 79 |
|
| 80 |
## Provenance
|
| 81 |
|
| 82 |
- Converted from the upstream checkpoint by the ExecuTorch team with the WebGPU export path.
|
| 83 |
- A reproducible export recipe will be published alongside the open-source ExecuTorch WebGPU runtime.
|
| 84 |
|
| 85 |
+
## Citation
|
| 86 |
+
|
| 87 |
+
If you use this model, please cite the original work:
|
| 88 |
+
|
| 89 |
+
```bibtex
|
| 90 |
+
@article{ravi2024sam2,
|
| 91 |
+
title={SAM 2: Segment Anything in Images and Videos},
|
| 92 |
+
author={Ravi, Nikhila and Gabeur, Valentin and Hu, Yuan-Ting and Hu, Ronghang and Ryali, Chaitanya and Ma, Tengyu and Khedr, Haitham and R{\"a}dle, Roman and Rolland, Chloe and Gustafson, Laura and Mintun, Eric and Pan, Junting and Alwala, Kalyan Vasudev and Carion, Nicolas and Wu, Chao-Yuan and Girshick, Ross and Doll{\'a}r, Piotr and Feichtenhofer, Christoph},
|
| 93 |
+
journal={arXiv preprint arXiv:2408.00714},
|
| 94 |
+
url={https://arxiv.org/abs/2408.00714},
|
| 95 |
+
year={2024}
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
## License
|
| 100 |
|
| 101 |
This is a derivative of the upstream model and is distributed under the same terms
|
| 102 |
(`apache-2.0`); see `LICENSE`.
|
| 103 |
+
Modifications (conversion to the ExecuTorch format) by Meta Platforms, Inc.
|