Instructions to use zeromodels/sam2_hiera_tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/sam2_hiera_tiny with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use zeromodels/sam2_hiera_tiny 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/sam2_hiera_tiny") - sam2
How to use zeromodels/sam2_hiera_tiny with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained(zeromodels/sam2_hiera_tiny) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained(zeromodels/sam2_hiera_tiny) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): state = predictor.init_state(<your_video>) # add new prompts and instantly get the output on the same frame frame_idx, object_ids, masks = predictor.add_new_points(state, <your_prompts>): # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
Upload kf_config.json with huggingface_hub
Browse files- kf_config.json +51 -0
kf_config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "kerasformers",
|
| 3 |
+
"kerasformers_version": "1.1.3",
|
| 4 |
+
"model_module": "kerasformers.models.sam2",
|
| 5 |
+
"model_class": "SAM2PromptableSegment",
|
| 6 |
+
"variant": "sam2_hiera_tiny",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"model_type": "sam2",
|
| 9 |
+
"hidden_dim": 96,
|
| 10 |
+
"blocks_per_stage": [
|
| 11 |
+
1,
|
| 12 |
+
2,
|
| 13 |
+
7,
|
| 14 |
+
2
|
| 15 |
+
],
|
| 16 |
+
"embed_dim_per_stage": [
|
| 17 |
+
96,
|
| 18 |
+
192,
|
| 19 |
+
384,
|
| 20 |
+
768
|
| 21 |
+
],
|
| 22 |
+
"num_attention_heads_per_stage": [
|
| 23 |
+
1,
|
| 24 |
+
2,
|
| 25 |
+
4,
|
| 26 |
+
8
|
| 27 |
+
],
|
| 28 |
+
"window_size_per_stage": [
|
| 29 |
+
8,
|
| 30 |
+
4,
|
| 31 |
+
14,
|
| 32 |
+
7
|
| 33 |
+
],
|
| 34 |
+
"global_attention_blocks": [
|
| 35 |
+
5,
|
| 36 |
+
7,
|
| 37 |
+
9
|
| 38 |
+
],
|
| 39 |
+
"backbone_channel_list": [
|
| 40 |
+
768,
|
| 41 |
+
384,
|
| 42 |
+
192,
|
| 43 |
+
96
|
| 44 |
+
],
|
| 45 |
+
"window_pos_embed_bg_size": null,
|
| 46 |
+
"num_multimask_outputs": 3,
|
| 47 |
+
"include_box_input": false,
|
| 48 |
+
"include_mask_input": false,
|
| 49 |
+
"multimask_output": true,
|
| 50 |
+
"image_size": 1024
|
| 51 |
+
}
|