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
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Browse files- README.md +18 -18
- kf_config.json → zm_config.json +51 -51
- kf_preprocessor.json → zm_preprocessor.json +18 -18
README.md
CHANGED
|
@@ -4,10 +4,10 @@ license: other
|
|
| 4 |
license_name: sam-license
|
| 5 |
license_link: https://github.com/facebookresearch/sam3/blob/main/LICENSE
|
| 6 |
base_model: facebook/sam3
|
| 7 |
-
library_name:
|
| 8 |
tags:
|
| 9 |
- keras
|
| 10 |
-
-
|
| 11 |
- sam3
|
| 12 |
- mask-generation
|
| 13 |
- image-segmentation
|
|
@@ -17,13 +17,13 @@ tags:
|
|
| 17 |
- tf
|
| 18 |
---
|
| 19 |
|
| 20 |
-
## ***See [our collection](https://huggingface.co/collections/
|
| 21 |
|
| 22 |
# Run SAM3 with Keras 3: JAX, PyTorch, or TensorFlow
|
| 23 |
|
| 24 |
-
[](https://arxiv.org/abs/2511.16719) · [HF Papers](https://huggingface.co/papers/2511.16719)
|
| 29 |
|
|
@@ -31,7 +31,7 @@ SAM3 segments by concept, not location: give it a noun phrase and it finds every
|
|
| 31 |
|
| 32 |
For more details on the model, please go to Meta's original [model card](https://huggingface.co/facebook/sam3).
|
| 33 |
|
| 34 |
-
Pure-**Keras 3** conversion of [`facebook/sam3`](https://huggingface.co/facebook/sam3) for [
|
| 35 |
|
| 36 |
This is a **concept-prompted** checkpoint (`SAM3InstanceSegment` / `SAM3Detect` / `SAM3SemanticSegment`): pass a text noun phrase (backbone ViT-L/14).
|
| 37 |
|
|
@@ -41,34 +41,34 @@ This is a **concept-prompted** checkpoint (`SAM3InstanceSegment` / `SAM3Detect`
|
|
| 41 |
import os
|
| 42 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 43 |
|
| 44 |
-
from
|
| 45 |
|
| 46 |
-
segmenter = SAM3InstanceSegment.from_weights("
|
| 47 |
result = segmenter.predict(
|
| 48 |
images="your_image.jpg", text="person", threshold=0.3
|
| 49 |
)[0]
|
| 50 |
print(len(result["scores"]), result["masks"].shape)
|
| 51 |
```
|
| 52 |
|
| 53 |
-
Load any SAM / SAM2 / SAM3 variant the same way with `from_weights("
|
| 54 |
|
| 55 |
| Variant | Hub | Family |
|
| 56 |
|---|---|---|
|
| 57 |
-
| `sam_vit_base` | [`
|
| 58 |
-
| `sam_vit_large` | [`
|
| 59 |
-
| `sam_vit_huge` | [`
|
| 60 |
-
| `sam2_hiera_small` | [`
|
| 61 |
-
| `sam2_hiera_base_plus` | [`
|
| 62 |
-
| `sam2_hiera_large` | [`
|
| 63 |
-
| `sam3` | [`
|
| 64 |
|
| 65 |
## Tips
|
| 66 |
|
| 67 |
-
- Set `KERAS_BACKEND` **before** importing Keras /
|
| 68 |
- SAM / SAM2: point coordinates are in original pixel space; box prompts need `enable_boxes=True` / `include_box_input=True` when building the graph.
|
| 69 |
- SAM2 in this port is image-only (no video memory bank).
|
| 70 |
- SAM3: prefer `SAM3InstanceSegment.predict(...)` for text prompts; upstream `facebook/sam3` is gated.
|
| 71 |
-
- See [SAM3 docs](https://imvision12.github.io/
|
| 72 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `SAM3Model.from_weights("hf:facebook/sam3")`.
|
| 73 |
|
| 74 |
## Special Thanks
|
|
|
|
| 4 |
license_name: sam-license
|
| 5 |
license_link: https://github.com/facebookresearch/sam3/blob/main/LICENSE
|
| 6 |
base_model: facebook/sam3
|
| 7 |
+
library_name: zeromodels
|
| 8 |
tags:
|
| 9 |
- keras
|
| 10 |
+
- zeromodels
|
| 11 |
- sam3
|
| 12 |
- mask-generation
|
| 13 |
- image-segmentation
|
|
|
|
| 17 |
- tf
|
| 18 |
---
|
| 19 |
|
| 20 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/sam-v1-v2-v3-6a6a8c261dabbc2996e1b4a2) for all versions of SAM.***
|
| 21 |
|
| 22 |
# Run SAM3 with Keras 3: JAX, PyTorch, or TensorFlow
|
| 23 |
|
| 24 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/sam3/) [](https://huggingface.co/collections/zeromodels/sam-v1-v2-v3-6a6a8c261dabbc2996e1b4a2)
|
| 25 |
|
| 26 |
+
# zeromodels/sam3
|
| 27 |
|
| 28 |
Paper: [SAM 3: Segment Anything with Concepts (arXiv:2511.16719)](https://arxiv.org/abs/2511.16719) · [HF Papers](https://huggingface.co/papers/2511.16719)
|
| 29 |
|
|
|
|
| 31 |
|
| 32 |
For more details on the model, please go to Meta's original [model card](https://huggingface.co/facebook/sam3).
|
| 33 |
|
| 34 |
+
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**.
|
| 35 |
|
| 36 |
This is a **concept-prompted** checkpoint (`SAM3InstanceSegment` / `SAM3Detect` / `SAM3SemanticSegment`): pass a text noun phrase (backbone ViT-L/14).
|
| 37 |
|
|
|
|
| 41 |
import os
|
| 42 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 43 |
|
| 44 |
+
from zeromodels.models.sam3 import SAM3InstanceSegment
|
| 45 |
|
| 46 |
+
segmenter = SAM3InstanceSegment.from_weights("zeromodels/sam3")
|
| 47 |
result = segmenter.predict(
|
| 48 |
images="your_image.jpg", text="person", threshold=0.3
|
| 49 |
)[0]
|
| 50 |
print(len(result["scores"]), result["masks"].shape)
|
| 51 |
```
|
| 52 |
|
| 53 |
+
Load any SAM / SAM2 / SAM3 variant the same way with `from_weights("zeromodels/<variant>")` (use `SAM3InstanceSegment` for this repo):
|
| 54 |
|
| 55 |
| Variant | Hub | Family |
|
| 56 |
|---|---|---|
|
| 57 |
+
| `sam_vit_base` | [`zeromodels/sam_vit_base`](https://huggingface.co/zeromodels/sam_vit_base) | SAM |
|
| 58 |
+
| `sam_vit_large` | [`zeromodels/sam_vit_large`](https://huggingface.co/zeromodels/sam_vit_large) | SAM |
|
| 59 |
+
| `sam_vit_huge` | [`zeromodels/sam_vit_huge`](https://huggingface.co/zeromodels/sam_vit_huge) | SAM |
|
| 60 |
+
| `sam2_hiera_small` | [`zeromodels/sam2_hiera_small`](https://huggingface.co/zeromodels/sam2_hiera_small) | SAM2 |
|
| 61 |
+
| `sam2_hiera_base_plus` | [`zeromodels/sam2_hiera_base_plus`](https://huggingface.co/zeromodels/sam2_hiera_base_plus) | SAM2 |
|
| 62 |
+
| `sam2_hiera_large` | [`zeromodels/sam2_hiera_large`](https://huggingface.co/zeromodels/sam2_hiera_large) | SAM2 |
|
| 63 |
+
| `sam3` | [`zeromodels/sam3`](https://huggingface.co/zeromodels/sam3) | SAM3 |
|
| 64 |
|
| 65 |
## Tips
|
| 66 |
|
| 67 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 68 |
- SAM / SAM2: point coordinates are in original pixel space; box prompts need `enable_boxes=True` / `include_box_input=True` when building the graph.
|
| 69 |
- SAM2 in this port is image-only (no video memory bank).
|
| 70 |
- SAM3: prefer `SAM3InstanceSegment.predict(...)` for text prompts; upstream `facebook/sam3` is gated.
|
| 71 |
+
- See [SAM3 docs](https://imvision12.github.io/ZeroModels/sam3/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 72 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `SAM3Model.from_weights("hf:facebook/sam3")`.
|
| 73 |
|
| 74 |
## Special Thanks
|
kf_config.json → zm_config.json
RENAMED
|
@@ -1,52 +1,52 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"model_module": "
|
| 5 |
-
"model_class": "SAM3Model",
|
| 6 |
-
"variant": "sam3",
|
| 7 |
-
"weights": "model.weights.h5",
|
| 8 |
-
"schema_version": 2,
|
| 9 |
-
"weight_dtype": "float32",
|
| 10 |
-
"model_type": "sam3",
|
| 11 |
-
"vision_config": {
|
| 12 |
-
"vit_hidden_size": 1024,
|
| 13 |
-
"vit_intermediate_size": 4736,
|
| 14 |
-
"vit_num_hidden_layers": 32,
|
| 15 |
-
"vit_num_attention_heads": 16,
|
| 16 |
-
"vit_image_size": 1008,
|
| 17 |
-
"vit_patch_size": 14,
|
| 18 |
-
"vit_window_size": 24,
|
| 19 |
-
"vit_global_attn_indexes": [
|
| 20 |
-
7,
|
| 21 |
-
15,
|
| 22 |
-
23,
|
| 23 |
-
31
|
| 24 |
-
],
|
| 25 |
-
"vit_rope_theta": 10000.0,
|
| 26 |
-
"vit_pretrain_image_size": 336,
|
| 27 |
-
"fpn_hidden_size": 256,
|
| 28 |
-
"fpn_scale_factors": [
|
| 29 |
-
4.0,
|
| 30 |
-
2.0,
|
| 31 |
-
1.0,
|
| 32 |
-
0.5
|
| 33 |
-
],
|
| 34 |
-
"detr_encoder_hidden_size": 256,
|
| 35 |
-
"detr_encoder_num_layers": 6,
|
| 36 |
-
"detr_encoder_num_attention_heads": 8,
|
| 37 |
-
"detr_encoder_intermediate_size": 2048,
|
| 38 |
-
"detr_encoder_dropout": 0.1,
|
| 39 |
-
"detr_decoder_hidden_size": 256,
|
| 40 |
-
"detr_decoder_num_layers": 6,
|
| 41 |
-
"detr_decoder_num_queries": 200,
|
| 42 |
-
"detr_decoder_num_attention_heads": 8,
|
| 43 |
-
"detr_decoder_intermediate_size": 2048,
|
| 44 |
-
"detr_decoder_dropout": 0.1,
|
| 45 |
-
"mask_decoder_hidden_size": 256,
|
| 46 |
-
"mask_decoder_num_upsampling_stages": 3,
|
| 47 |
-
"mask_decoder_num_attention_heads": 8,
|
| 48 |
-
"text_hidden_size": 1024,
|
| 49 |
-
"text_projection_dim": 512,
|
| 50 |
-
"image_size": 1008
|
| 51 |
-
}
|
| 52 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.1",
|
| 4 |
+
"model_module": "zeromodels.models.sam3",
|
| 5 |
+
"model_class": "SAM3Model",
|
| 6 |
+
"variant": "sam3",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"weight_dtype": "float32",
|
| 10 |
+
"model_type": "sam3",
|
| 11 |
+
"vision_config": {
|
| 12 |
+
"vit_hidden_size": 1024,
|
| 13 |
+
"vit_intermediate_size": 4736,
|
| 14 |
+
"vit_num_hidden_layers": 32,
|
| 15 |
+
"vit_num_attention_heads": 16,
|
| 16 |
+
"vit_image_size": 1008,
|
| 17 |
+
"vit_patch_size": 14,
|
| 18 |
+
"vit_window_size": 24,
|
| 19 |
+
"vit_global_attn_indexes": [
|
| 20 |
+
7,
|
| 21 |
+
15,
|
| 22 |
+
23,
|
| 23 |
+
31
|
| 24 |
+
],
|
| 25 |
+
"vit_rope_theta": 10000.0,
|
| 26 |
+
"vit_pretrain_image_size": 336,
|
| 27 |
+
"fpn_hidden_size": 256,
|
| 28 |
+
"fpn_scale_factors": [
|
| 29 |
+
4.0,
|
| 30 |
+
2.0,
|
| 31 |
+
1.0,
|
| 32 |
+
0.5
|
| 33 |
+
],
|
| 34 |
+
"detr_encoder_hidden_size": 256,
|
| 35 |
+
"detr_encoder_num_layers": 6,
|
| 36 |
+
"detr_encoder_num_attention_heads": 8,
|
| 37 |
+
"detr_encoder_intermediate_size": 2048,
|
| 38 |
+
"detr_encoder_dropout": 0.1,
|
| 39 |
+
"detr_decoder_hidden_size": 256,
|
| 40 |
+
"detr_decoder_num_layers": 6,
|
| 41 |
+
"detr_decoder_num_queries": 200,
|
| 42 |
+
"detr_decoder_num_attention_heads": 8,
|
| 43 |
+
"detr_decoder_intermediate_size": 2048,
|
| 44 |
+
"detr_decoder_dropout": 0.1,
|
| 45 |
+
"mask_decoder_hidden_size": 256,
|
| 46 |
+
"mask_decoder_num_upsampling_stages": 3,
|
| 47 |
+
"mask_decoder_num_attention_heads": 8,
|
| 48 |
+
"text_hidden_size": 1024,
|
| 49 |
+
"text_projection_dim": 512,
|
| 50 |
+
"image_size": 1008
|
| 51 |
+
}
|
| 52 |
}
|
kf_preprocessor.json → zm_preprocessor.json
RENAMED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"preprocessor_module": "
|
| 5 |
-
"preprocessor_class": "SAM3ImageProcessor",
|
| 6 |
-
"variant": "sam3",
|
| 7 |
-
"image_resolution": 1008,
|
| 8 |
-
"image_mean": [
|
| 9 |
-
0.5,
|
| 10 |
-
0.5,
|
| 11 |
-
0.5
|
| 12 |
-
],
|
| 13 |
-
"image_std": [
|
| 14 |
-
0.5,
|
| 15 |
-
0.5,
|
| 16 |
-
0.5
|
| 17 |
-
],
|
| 18 |
-
"rescale_factor": 0.00392156862745098
|
| 19 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.3",
|
| 4 |
+
"preprocessor_module": "zeromodels.models.sam3",
|
| 5 |
+
"preprocessor_class": "SAM3ImageProcessor",
|
| 6 |
+
"variant": "sam3",
|
| 7 |
+
"image_resolution": 1008,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_std": [
|
| 14 |
+
0.5,
|
| 15 |
+
0.5,
|
| 16 |
+
0.5
|
| 17 |
+
],
|
| 18 |
+
"rescale_factor": 0.00392156862745098
|
| 19 |
}
|