prasadsachin commited on
Commit
6fc21d5
·
verified ·
1 Parent(s): 7b932f9

Update README.md with new model card content

Browse files
Files changed (1) hide show
  1. README.md +86 -13
README.md CHANGED
@@ -1,16 +1,89 @@
1
  ---
2
  library_name: keras-hub
3
  ---
4
- This is a [`SAM3PromptableConcept` model](https://keras.io/api/keras_hub/models/sam3_promptable_concept) uploaded using the KerasHub library and can be used with JAX, TensorFlow, and PyTorch backends.
5
- Model config:
6
- * **name:** sam3_promptable_concept_backbone
7
- * **trainable:** True
8
- * **dtype:** {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}
9
- * **vision_encoder:** {'module': 'keras_hub.src.models.sam3.sam3_vision_encoder', 'class_name': 'SAM3VisionEncoder', 'config': {'name': 'sam3_vision_encoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'image_shape': [1008, 1008, 3], 'patch_size': 14, 'num_layers': 32, 'hidden_dim': 1024, 'intermediate_dim': 4736, 'num_heads': 16, 'fpn_hidden_dim': 256, 'fpn_scale_factors': [4.0, 2.0, 1.0, 0.5], 'pretrain_image_shape': [336, 336, 3], 'hidden_activation': 'gelu', 'rope_theta': 10000.0, 'window_size': 24, 'global_attn_indexes': [7, 15, 23, 31], 'attention_dropout_rate': 0.0, 'hidden_dropout_rate': 0.0, 'layer_norm_epsilon': 1e-06}, 'registered_name': 'keras_hub>SAM3VisionEncoder'}
10
- * **text_encoder:** {'module': 'keras_hub.src.models.sam3.sam3_text_encoder', 'class_name': 'SAM3TextEncoder', 'config': {'name': 'sam3_text_encoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'vocabulary_size': 49408, 'embedding_dim': 1024, 'hidden_dim': 1024, 'num_layers': 24, 'num_heads': 16, 'intermediate_dim': 4096, 'intermediate_activation': 'gelu', 'max_sequence_length': 32, 'layer_norm_epsilon': 1e-05}, 'registered_name': 'keras_hub>SAM3TextEncoder'}
11
- * **geometry_encoder:** {'module': 'keras_hub.src.models.sam3.sam3_geometry_encoder', 'class_name': 'SAM3GeometryEncoder', 'config': {'name': 'sam3_geometry_encoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'num_layers': 3, 'hidden_dim': 256, 'intermediate_dim': 2048, 'num_heads': 8, 'roi_size': 7, 'hidden_activation': 'relu', 'dropout_rate': 0.0, 'layer_norm_epsilon': 1e-06}, 'registered_name': 'keras_hub>SAM3GeometryEncoder'}
12
- * **detr_encoder:** {'module': 'keras_hub.src.models.sam3.sam3_detr_encoder', 'class_name': 'SAM3DetrEncoder', 'config': {'name': 'sam3_detr_encoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'num_layers': 6, 'hidden_dim': 256, 'intermediate_dim': 2048, 'num_heads': 8, 'hidden_activation': 'relu', 'dropout_rate': 0.1, 'layer_norm_epsilon': 1e-06}, 'registered_name': 'keras_hub>SAM3DetrEncoder'}
13
- * **detr_decoder:** {'module': 'keras_hub.src.models.sam3.sam3_detr_decoder', 'class_name': 'SAM3DetrDecoder', 'config': {'name': 'sam3_detr_decoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'image_shape': [1008, 1008, 3], 'patch_size': 14, 'num_layers': 6, 'hidden_dim': 256, 'intermediate_dim': 2048, 'num_heads': 8, 'num_queries': 200, 'hidden_activation': 'relu', 'dropout_rate': 0.1, 'layer_norm_epsilon': 1e-06}, 'registered_name': 'keras_hub>SAM3DetrDecoder'}
14
- * **mask_decoder:** {'module': 'keras_hub.src.models.sam3.sam3_mask_decoder', 'class_name': 'SAM3MaskDecoder', 'config': {'name': 'sam3_mask_decoder', 'trainable': True, 'dtype': {'module': 'keras', 'class_name': 'DTypePolicy', 'config': {'name': 'float32'}, 'registered_name': None}, 'num_upsampling_stages': 3, 'hidden_dim': 256, 'num_heads': 8, 'dropout_rate': 0.0, 'layer_norm_epsilon': 1e-06}, 'registered_name': 'keras_hub>SAM3MaskDecoder'}
15
-
16
- This model card has been generated automatically and should be completed by the model author. See [Model Cards documentation](https://huggingface.co/docs/hub/model-cards) for more information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: keras-hub
3
  ---
4
+ ### Model Overview
5
+ # SAM 3
6
+
7
+ The Segment Anything Model 3 (SAM 3) is a high-performance foundation model for promptable object segmentation in images. Building upon the breakthroughs of previous SAM iterations, SAM 3 is designed for real-time performance, superior mask quality, and improved zero-shot generalization across diverse visual domains.
8
+
9
+ ## Model Summary
10
+
11
+ SAM 3 follows the "Segment Anything" philosophy by providing a universal interface for segmentation via prompts such as points, bounding boxes, or previous masks. It features a decoupled architecture that separates heavy image encoding from lightweight prompt processing, allowing the model to generate masks in near real-time once an image embedding has been computed.
12
+
13
+ SAM3 promptable concept segmentation (PCS) segments objects in images based
14
+ on concept prompts, which could be short noun phrases (e.g., “yellow school bus”), image exemplars, or a combination of both. SAM3 PCS takes such prompts and returns segmentation masks and unique identities for all matching object instances.
15
+
16
+ There are two ways to prompt:
17
+ 1. Text prompt: A short noun phrase describing the concept to segment.
18
+ 2. Box prompt: A box tells the model which part/crop of the image to
19
+ segment.
20
+
21
+ These prompts can be used individually or together, but at least one of the prompts must be present. To turn off a particular prompt, simply exclude it from the inputs to the model.
22
+
23
+ This modular design allows users to swap backbones of varying sizes (Tiny, Small, Base, Large) depending on the hardware constraints and accuracy requirements.
24
+
25
+ ## References
26
+
27
+ * [SAM 3 Quickstart Notebook](Coming Soon)
28
+ * [SAM 3 API Documentation](https://keras.io/keras_hub/api/models/sam3/)
29
+ * [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/)
30
+ * [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/)
31
+ * [Segment Anything 3 Technical Report](https://huggingface.co/facebook/sam3)
32
+
33
+ ## Installation
34
+
35
+ Keras and KerasHub can be installed using the following commands:
36
+
37
+ ```bash
38
+ pip install -U -q keras-hub
39
+ pip install -U -q keras
40
+ ```
41
+
42
+ The following table summarizes the different configurations available for SAM 3 in Keras Hub:
43
+
44
+ | Preset | Parameters | Description |
45
+ | ---------------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
46
+ | `sam3_pcs` | ~30M | Promptable Concept Segmentation (PCS) SAM model|
47
+
48
+ ## Example Usage
49
+ ```python
50
+ image_size = 128
51
+ batch_size = 2
52
+ input_data = {
53
+ "images": np.ones(
54
+ (batch_size, image_size, image_size, 3), dtype="float32",
55
+ ),
56
+ "prompts": ["ear", "head"],
57
+ "boxes": np.ones((batch_size, 1, 4), dtype="float32"), # XYXY format.
58
+ "box_labels": np.ones((batch_size, 1), dtype="float32"),
59
+ }
60
+ sam3_pcs = keras_hub.models.SAM3PromptableConceptImageSegmenter.from_preset(
61
+ "sam3_pcs"
62
+ )
63
+ outputs = sam3_pcs.predict(input_data)
64
+ scores = outputs["scores"] # [B, num_queries]
65
+ boxes = outputs["boxes"] # [B, num_queries, 4]
66
+ masks = outputs["masks"] # [B, num_queries, H, W]
67
+ ```
68
+
69
+ ## Example Usage with Hugging Face URI
70
+
71
+ ```python
72
+ image_size = 128
73
+ batch_size = 2
74
+ input_data = {
75
+ "images": np.ones(
76
+ (batch_size, image_size, image_size, 3), dtype="float32",
77
+ ),
78
+ "prompts": ["ear", "head"],
79
+ "boxes": np.ones((batch_size, 1, 4), dtype="float32"), # XYXY format.
80
+ "box_labels": np.ones((batch_size, 1), dtype="float32"),
81
+ }
82
+ hf://keras/sam3_pcs = keras_hub.models.SAM3PromptableConceptImageSegmenter.from_preset(
83
+ "hf://keras/sam3_pcs"
84
+ )
85
+ outputs = hf://keras/sam3_pcs.predict(input_data)
86
+ scores = outputs["scores"] # [B, num_queries]
87
+ boxes = outputs["boxes"] # [B, num_queries, 4]
88
+ masks = outputs["masks"] # [B, num_queries, H, W]
89
+ ```