Instructions to use zeromodels/sam3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/sam3 with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/sam3") - Notebooks
- Google Colab
- Kaggle
File size: 4,084 Bytes
fd6210a 24423ed fd6210a 24423ed fd6210a 72b3040 fd6210a 72b3040 fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a 24423ed fd6210a | 1 2 3 4 5 6 7 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 | ---
pipeline_tag: mask-generation
license: other
license_name: sam-license
license_link: https://github.com/facebookresearch/sam3/blob/main/LICENSE
base_model: facebook/sam3
library_name: zeromodels
tags:
- keras
- zeromodels
- sam3
- mask-generation
- image-segmentation
- arxiv:2511.16719
- pytorch
- jax
- tf
---
## ***See [our collection](https://huggingface.co/collections/zeromodels/sam-v1-v2-v3-6a8eaf73a274fffa2ea83cfd) for all versions of SAM.***
# Run SAM3 with Keras 3: JAX, PyTorch, or TensorFlow
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/sam3/) [](https://huggingface.co/collections/zeromodels/sam-v1-v2-v3-6a8eaf73a274fffa2ea83cfd)
# zeromodels/sam3
Paper: [SAM 3: Segment Anything with Concepts (arXiv:2511.16719)](https://arxiv.org/abs/2511.16719) · [HF Papers](https://huggingface.co/papers/2511.16719)
SAM3 segments by concept, not location: give it a noun phrase and it finds every matching instance. A ViT-L backbone and FPN feed a DETR-style encoder/decoder with object queries; a CLIP text encoder supplies the open-vocabulary side. Boxes can still be mixed with text.
For more details on the model, please go to Meta's original [model card](https://huggingface.co/facebook/sam3).
Pure-**Keras 3** conversion of [`facebook/sam3`](https://huggingface.co/facebook/sam3) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
This is a **concept-prompted** checkpoint (`SAM3InstanceSegment` / `SAM3Detect` / `SAM3SemanticSegment`): pass a text noun phrase (backbone ViT-L/14).
## ✨ Quick start
```python
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from zeromodels.models.sam3 import SAM3InstanceSegment
segmenter = SAM3InstanceSegment.from_weights("zeromodels/sam3")
result = segmenter.predict(
images="your_image.jpg", text="person", threshold=0.3
)[0]
print(len(result["scores"]), result["masks"].shape)
```
Load any SAM / SAM2 / SAM3 variant the same way with `from_weights("zeromodels/<variant>")` (use `SAM3InstanceSegment` for this repo):
| Variant | Hub | Family |
|---|---|---|
| `sam_vit_base` | [`zeromodels/sam_vit_base`](https://huggingface.co/zeromodels/sam_vit_base) | SAM |
| `sam_vit_large` | [`zeromodels/sam_vit_large`](https://huggingface.co/zeromodels/sam_vit_large) | SAM |
| `sam_vit_huge` | [`zeromodels/sam_vit_huge`](https://huggingface.co/zeromodels/sam_vit_huge) | SAM |
| `sam2_hiera_small` | [`zeromodels/sam2_hiera_small`](https://huggingface.co/zeromodels/sam2_hiera_small) | SAM2 |
| `sam2_hiera_base_plus` | [`zeromodels/sam2_hiera_base_plus`](https://huggingface.co/zeromodels/sam2_hiera_base_plus) | SAM2 |
| `sam2_hiera_large` | [`zeromodels/sam2_hiera_large`](https://huggingface.co/zeromodels/sam2_hiera_large) | SAM2 |
| `sam3` | [`zeromodels/sam3`](https://huggingface.co/zeromodels/sam3) | SAM3 |
## Tips
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
- SAM / SAM2: point coordinates are in original pixel space; box prompts need `enable_boxes=True` / `include_box_input=True` when building the graph.
- SAM2 in this port is image-only (no video memory bank).
- SAM3: prefer `SAM3InstanceSegment.predict(...)` for text prompts; upstream `facebook/sam3` is gated.
- See [SAM3 docs](https://imvision12.github.io/ZeroModels/sam3/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `SAM3Model.from_weights("hf:facebook/sam3")`.
## Special Thanks
A huge thank you to the Meta SAM 3 authors for creating and releasing these models.
License: see the [SAM 3 LICENSE](https://github.com/facebookresearch/sam3/blob/main/LICENSE) (Hub tag: `other` / `sam-license`). Upstream [`facebook/sam3`](https://huggingface.co/facebook/sam3) is gated.
|