Skip to content
ModelListedExternal
Download

Segment Anything 2 Onnx Models

ONNX exports of Meta's SAM 2 image-segmentation backbones, packaged for direct use with onnxruntime and AnyLabeling.

KindOtherVersionRevision 071f580Cgrade

Model source

Kind
Other
File size
19.7–848 MB
Version
vRevision 071f580
Updated
Sep 16, 2026
Downloads
0
Source
Hugging Face

Source excerpt

ONNX exports of Meta's SAM 2 image-segmentation backbones, packaged for direct use with onnxruntime and AnyLabeling.

Sources

1 source
Hugging FacePrimaryVersion 071f58077599431edd0e5d2ac52ecca4c78f1cab
huggingface.co/vietanhdev/segment-anything-2-onnx-models/tree/071f58077599431edd0e5d2ac52ecca4c78f1cab

Verified Sep 1

Model artifacts

8 artifacts

sam2_hiera_base_plus.decoder.onnx

onnx · 19.7 MB · SHA-256 666f00ce2664…03b4 · Hugging Face

Download

sam2_hiera_base_plus.encoder.onnx

onnx · 324 MB · SHA-256 53b79cec15f2…cc8d · Hugging Face

Download

sam2_hiera_large.decoder.onnx

onnx · 19.7 MB · SHA-256 2b5a3d40a017…ca07 · Hugging Face

Download

sam2_hiera_large.encoder.onnx

onnx · 848 MB · SHA-256 cb252d7b59fd…b617 · Hugging Face

Download

sam2_hiera_small.decoder.onnx

onnx · 19.7 MB · SHA-256 e07f799d2afe…047b · Hugging Face

Download

sam2_hiera_small.encoder.onnx

onnx · 155 MB · SHA-256 f6a7c74dee5b…7f40 · Hugging Face

Download

sam2_hiera_tiny.decoder.onnx

onnx · 19.7 MB · SHA-256 f5a4bd656c14…87bf · Hugging Face

Download

sam2_hiera_tiny.encoder.onnx

onnx · 128 MB · SHA-256 4cc015ee1852…82f7 · Hugging Face

Download

Source excerpts

2 excerpts

--- 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