Segment Anything 2 Onnx Models
ONNX exports of Meta's SAM 2 image-segmentation backbones, packaged for direct use with onnxruntime and AnyLabeling.
Fonte do modelo
- Tipo
- Other
- Tamanho do arquivo
- 19,7–848 MB
- Versão
- vRevision 071f580
- Atualizado
- 16 de set. de 2026
- Downloads
- 0
- Fonte
- Hugging Face
Trecho da fonte
ONNX exports of Meta's SAM 2 image-segmentation backbones, packaged for direct use with onnxruntime and AnyLabeling.
Fontes
1 fonte
Fontes
1 fonteVerificado 1 de set.
Artefatos de modelo
8 artefatos
Artefatos de modelo
8 artefatosTrechos de fonte
2 trechos
Trechos de fonte
2 trechos--- license: apache-2.0 pipeline_tag: image-segmentation library_name: onnx tags: - onnxruntime - onnx - segment-anything - segment-anything-2 - image-segmentation - edge-ai - anylabeling authors: - Viet-Anh Nguyen --- # Segment Anything 2 (SAM 2) — ONNX Models ONNX exports of Meta's [SAM 2](https://github.com/facebookresearch/sam2) image-segmentation backbones, packaged for direct use with [`onnxruntime`](https://onnxruntime.ai) and [AnyLabeling](https://github.com/vietanhdev/anylabeling). ## Why this repo exists SAM 2 is materially better than SAM 1 on speed and quality, but the official release ships PyTorch checkpoints. 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. ## Variants Each backbone is provided in two equivalent forms — pick whichever fits your loader: - **Raw ONNX pair**: `<backbone>.encoder.onnx` + `<backbone>.decoder.onnx` - **Bundled zip**: `<backbone>.zip` containing both files | Backbone | Encoder size | Decoder size | Bundle | |---|---|---|---| | `sam2_hiera_tiny` | 128 MB | 19.7 MB | `sam2_hiera_tiny.zip` (148 MB) | | `sam2_hiera_small` | 155 MB | 19.7 MB | `sam2_hiera_small.zip` (175 MB) | | `sam2_hiera_base_plus` | 324 MB | 19.7 MB | `sam2_hiera_base_plus.zip` (344 MB) | | `sam2_hiera_large` | 848 MB | 19.7 MB | `sam2_hiera_large.zip` (868 MB) | `zip_models.py` is the helper script used to produce the bundled zips from the encoder/decoder pairs. ## Quick start ```bash pip install huggingface_hub onnxruntime ``` ```python from huggingface_hub import hf_hub_download import onnxruntime as ort repo = "vietanhdev/segment-anything-2-onnx-models" encoder = hf_hub_download(repo_id=repo, filename="sam2_hiera_tiny.encoder.onnx") decoder = hf_hub_download(repo_id=repo, filename="sam2_hiera_tiny.decoder.onnx") enc = ort.InferenceSession(encoder, providers=["CPUExecutionProvider"]) dec = ort.InferenceSession(decoder, providers=["CPUExecutionProvider"]) # Inspect expected inputs: print("Encoder:", [(i.name, i.shape, i.type) for i in enc.get_inputs()]) print("Decoder:", [(i.name, i.shape, i.type) for i in dec.get_inputs()]) ``` For the full image → mask pipeline (encoder + decoder + prompt handling), see how AnyLabeling wires it: <https://github.com/vietanhdev/anylabeling>...
Source context: 0 downloads · 15 likes · Pipeline image-segmentation · Library onnx · Repo vietanhdev/segment-anything-2-onnx-models
