docs: rewrite model card with variants table, citation, AnyLabeling cross-link
Browse files
README.md
CHANGED
|
@@ -1,106 +1,92 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
- onnx
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
```
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
#
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
## Related Repositories
|
| 95 |
-
|
| 96 |
-
| Repo | Description |
|
| 97 |
-
|------|-------------|
|
| 98 |
-
| [vietanhdev/samexporter](https://github.com/vietanhdev/samexporter) | Export scripts, inference code, conversion tools |
|
| 99 |
-
| [vietanhdev/anylabeling](https://github.com/vietanhdev/anylabeling) | Desktop annotation app powered by these models |
|
| 100 |
-
| [vietanhdev/segment-anything-2-onnx-models](https://huggingface.co/vietanhdev/segment-anything-2-onnx-models) | Original SAM 2 ONNX models |
|
| 101 |
-
| [facebookresearch/segment-anything-2](https://github.com/facebookresearch/segment-anything-2) | Original SAM 2 / SAM 2.1 by Meta |
|
| 102 |
-
|
| 103 |
-
## License
|
| 104 |
-
|
| 105 |
-
The ONNX models are derived from Meta's SAM 2.1, released under the **Apache 2.0** license.
|
| 106 |
-
The export code is part of [samexporter](https://github.com/vietanhdev/samexporter), released under the **MIT** license.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: image-segmentation
|
| 4 |
+
library_name: onnx
|
| 5 |
+
tags:
|
| 6 |
+
- onnxruntime
|
| 7 |
+
- onnx
|
| 8 |
+
- segment-anything
|
| 9 |
+
- segment-anything-2
|
| 10 |
+
- segment-anything-2.1
|
| 11 |
+
- image-segmentation
|
| 12 |
+
- edge-ai
|
| 13 |
+
- anylabeling
|
| 14 |
+
authors:
|
| 15 |
+
- Viet-Anh Nguyen
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Segment Anything 2.1 (SAM 2.1) — ONNX Models
|
| 19 |
+
|
| 20 |
+
ONNX exports of Meta's [SAM 2.1](https://github.com/facebookresearch/sam2) backbones — the maintenance release of SAM 2 — packaged for direct use with [`onnxruntime`](https://onnxruntime.ai) and [AnyLabeling](https://github.com/vietanhdev/anylabeling).
|
| 21 |
+
|
| 22 |
+
## Why this repo exists
|
| 23 |
+
|
| 24 |
+
SAM 2.1 ships incremental quality improvements over SAM 2 with the same architecture and runtime cost. ONNX gives you a portable, dependency-light runtime that works in Python, C++, JavaScript, and most embedded targets. These exports are the ones AnyLabeling consumes for its smart-labeling features.
|
| 25 |
+
|
| 26 |
+
## Variants
|
| 27 |
+
|
| 28 |
+
Each `.zip` bundles the encoder + decoder ONNX files for that backbone. The `_20260221` suffix is the export date.
|
| 29 |
+
|
| 30 |
+
| File | Backbone | Size |
|
| 31 |
+
|---|---|---|
|
| 32 |
+
| `sam2.1_hiera_tiny_20260221.zip` | Hiera-T | 111 MB |
|
| 33 |
+
| `sam2.1_hiera_small_20260221.zip` | Hiera-S | 136 MB |
|
| 34 |
+
| `sam2.1_hiera_base_plus_20260221.zip` | Hiera-B+ | 259 MB |
|
| 35 |
+
| `sam2.1_hiera_large_20260221.zip` | Hiera-L | 768 MB |
|
| 36 |
+
|
| 37 |
+
## Quick start
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install huggingface_hub onnxruntime
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from huggingface_hub import hf_hub_download
|
| 45 |
+
import zipfile, onnxruntime as ort
|
| 46 |
+
|
| 47 |
+
zip_path = hf_hub_download(repo_id="vietanhdev/segment-anything-2.1-onnx-models",
|
| 48 |
+
filename="sam2.1_hiera_tiny_20260221.zip")
|
| 49 |
+
with zipfile.ZipFile(zip_path) as z:
|
| 50 |
+
z.extractall("./sam21_tiny")
|
| 51 |
+
|
| 52 |
+
enc = ort.InferenceSession("./sam21_tiny/encoder.onnx", providers=["CPUExecutionProvider"])
|
| 53 |
+
print([(i.name, i.shape, i.type) for i in enc.get_inputs()])
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
For the full image → mask pipeline (encoder + decoder + prompt handling), see how AnyLabeling wires it: <https://github.com/vietanhdev/anylabeling>
|
| 57 |
+
|
| 58 |
+
## Use with AnyLabeling
|
| 59 |
+
|
| 60 |
+
These models drop into AnyLabeling's auto-labeling backend without conversion. See the [AnyLabeling docs](https://github.com/vietanhdev/anylabeling) for the model-config wiring.
|
| 61 |
+
|
| 62 |
+
## Source weights
|
| 63 |
+
|
| 64 |
+
Original SAM 2.1 weights and license: <https://github.com/facebookresearch/sam2>
|
| 65 |
+
|
| 66 |
+
This repo redistributes the same weights in ONNX format. License unchanged from upstream (Apache 2.0).
|
| 67 |
+
|
| 68 |
+
## Citation
|
| 69 |
+
|
| 70 |
+
```bibtex
|
| 71 |
+
@misc{nguyen2026sam21_onnx,
|
| 72 |
+
author = {Nguyen, Viet-Anh and {Neural Research Lab}},
|
| 73 |
+
title = {SAM 2.1 ONNX Models},
|
| 74 |
+
year = {2026},
|
| 75 |
+
url = {https://huggingface.co/vietanhdev/segment-anything-2.1-onnx-models}
|
| 76 |
+
}
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
For the underlying model, cite Meta's SAM 2 paper (SAM 2.1 is a release of the same model family):
|
| 80 |
+
|
| 81 |
+
```bibtex
|
| 82 |
+
@article{ravi2024sam2,
|
| 83 |
+
title = {SAM 2: Segment Anything in Images and Videos},
|
| 84 |
+
author = {Ravi, Nikhila and others},
|
| 85 |
+
journal = {arXiv:2408.00714},
|
| 86 |
+
year = {2024}
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
## Acknowledgments
|
| 91 |
+
|
| 92 |
+
Thanks to Meta AI Research for the SAM 2.x line. This repo packages their work for edge inference.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|