Segment Anything 3 (SAM 3), image (fastforks)
Segment Anything 3 (Meta, 2025), image mode: promptable concept segmentation, every instance matching a text and / or exemplar-box prompt (positive / negative boxes; returns boxes, scores, masks). A ViT trunk with an FPN neck, a CLIP text encoder, a geometry encoder, a DETR encoder / decoder with a presence token and a mask decoder (no video tracker). The portable module() is the image encoder only.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/facebookresearch/sam3 at 0570b3a.
Author weight repos: https://huggingface.co/facebook/sam3.
Task: promptable_segmentation. Tier: stable. Outputs: boxes, scores, masks. Backends: portable, kernels.
Input: one image plus a point, box or text prompt. Output: masks with quality scores.
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
sam3@1 |
model.safetensors vocab.json merges.txt |
6d06f0a5f84e5047b556ce869fd691f7c803 |
LicenseRef-SAM-License | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: LicenseRef-SAM-License AND Apache-2.0. Files: LICENSE, LICENSE-transformers.
Training data: the SA-Co data engine's image and video annotations plus public and internal datasets per the paper; not released as one dataset.
- Licence note: The weights use Meta's SAM License, not Apache-2.0; its terms were not re-checked here.
Licence evidence: https://huggingface.co/facebook/sam3/blob/main/LICENSE (SAM License, Nov 19 2025); the weights are gated: download them from Meta's Hugging Face repo after accepting the licence and point FASTFORKS_WEIGHTS_PATH at the local copy; fastforks never mirrors them
Input size
any H x W >= 1, resized inside to the fixed encoder input 1008x1008 (the default export size)
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): sam3 1080x1920 (1.9 GiB peak allocated, 2.1 reserved)
Speed and memory
Promptable segmentation, synthetic, 1024x1024
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
sam3 |
694.95 | 281.04 | 179.43 | 116.47 | 2.4x | 1.5x | 5255 / 5334 | 1922 / 2004 | 2019 / 2264 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
sam3 |
1.12 (840x1297) | 2.95 | 0.70โ | 0.96 (840x1297) | 0.18โ | 0.12โ |
Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|---|---|---|---|---|---|
sam3 |
portable | 179.8 ms / 1928 / 2196 | 181.5 ms / 1935 / 2208 | 182.6 ms / 1948 / 2192 | - |
sam3 |
kernels | 116.3 ms / 2052 / 2460 | 116.5 ms / 2059 / 2420 | 116.9 ms / 2072 / 2490 | - |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
Parity with the original code
Every variant is checked against golden outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.0005 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.35 px and p99 <= 2.0 px.
Usage
from fastforks import promptable_segmentation
model = promptable_segmentation.load("sam3") # portable PyTorch on the GPU if there is one, else the CPU
result = model("photo.jpg", input_points=[[x, y]], input_labels=[1])
result.masks # [M, H, W] bool
# SAM 3 (text prompts): model("photo.jpg", text="coin") -> boxes, scores, masks
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: sam3.
Kernels backend
promptable_segmentation.load("sam3", mode="kernels") runs our CUDA kernels (fastbb, cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.