Segment Anything 2 Model¶
Class: SegmentAnything2BlockV1
Source: inference.core.workflows.core_steps.models.foundation.segment_anything2.v1.SegmentAnything2BlockV1
Run Segment Anything 2, a zero-shot instance segmentation model, on an image.
** Dedicated inference server required (GPU recomended) **
You can use pass in boxes/predictions from other models to Segment Anything 2 to use as prompts for the model. If you pass in box detections from another model, the class names of the boxes will be forwarded to the predicted masks. If using the model unprompted, the model will assign integers as class names / ids.
Type identifier¶
Use the following identifier in step "type"
field: roboflow_core/segment_anything@v1
to add the block as
as step in your workflow.
Properties¶
Name | Type | Description | Refs |
---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
version |
str |
Model to be used. One of hiera_large, hiera_small, hiera_tiny, hiera_b_plus. | ✅ |
threshold |
float |
Threshold for predicted masks scores. | ✅ |
multimask_output |
bool |
Flag to determine whether to use sam2 internal multimask or single mask mode. For ambiguous prompts setting to True is recomended.. | ✅ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow
runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Segment Anything 2 Model
in version v1
.
- inputs:
VLM as Classifier
,Path Deviation
,Stability AI Inpainting
,Byte Tracker
,Image Slicer
,Path Deviation
,Keypoint Detection Model
,Multi-Label Classification Model
,Halo Visualization
,VLM as Detector
,Identify Changes
,Time in Zone
,Image Contours
,Roboflow Dataset Upload
,Image Threshold
,Slack Notification
,Instance Segmentation Model
,CSV Formatter
,Detections Transformation
,Time in Zone
,Florence-2 Model
,Dynamic Crop
,Mask Visualization
,Roboflow Dataset Upload
,Local File Sink
,Identify Outliers
,OCR Model
,VLM as Detector
,Template Matching
,Polygon Zone Visualization
,Image Convert Grayscale
,OpenAI
,Detections Classes Replacement
,Polygon Visualization
,LMM
,Reference Path Visualization
,Classification Label Visualization
,SIFT Comparison
,Label Visualization
,Perspective Correction
,Google Gemini
,Instance Segmentation Model
,Byte Tracker
,Llama 3.2 Vision
,Anthropic Claude
,Roboflow Custom Metadata
,JSON Parser
,Keypoint Visualization
,Corner Visualization
,Byte Tracker
,Camera Focus
,Segment Anything 2 Model
,Detection Offset
,Gaze Detection
,Bounding Box Visualization
,SIFT Comparison
,Keypoint Detection Model
,Detections Consensus
,VLM as Classifier
,Cosine Similarity
,Image Preprocessing
,Line Counter Visualization
,Model Monitoring Inference Aggregator
,Florence-2 Model
,Absolute Static Crop
,Pixelate Visualization
,Crop Visualization
,Trace Visualization
,Background Color Visualization
,Detections Stabilizer
,Twilio SMS Notification
,Circle Visualization
,YOLO-World Model
,Blur Visualization
,Detections Stitch
,Email Notification
,OpenAI
,Stability AI Image Generation
,Google Vision OCR
,SIFT
,Stitch Images
,Webhook Sink
,Model Comparison Visualization
,Line Counter
,Stitch OCR Detections
,CogVLM
,Relative Static Crop
,Clip Comparison
,Triangle Visualization
,Bounding Rectangle
,Detections Filter
,LMM For Classification
,Ellipse Visualization
,Object Detection Model
,Color Visualization
,Dot Visualization
,Single-Label Classification Model
,Grid Visualization
,Image Blur
,Object Detection Model
- outputs:
Roboflow Custom Metadata
,Byte Tracker
,Corner Visualization
,Segment Anything 2 Model
,Detection Offset
,Path Deviation
,Stability AI Inpainting
,Byte Tracker
,Bounding Box Visualization
,Detections Consensus
,Model Monitoring Inference Aggregator
,Dynamic Zone
,Path Deviation
,Florence-2 Model
,Pixelate Visualization
,Trace Visualization
,Crop Visualization
,Background Color Visualization
,Halo Visualization
,Time in Zone
,Size Measurement
,Detections Stabilizer
,Roboflow Dataset Upload
,Circle Visualization
,Blur Visualization
,Detections Stitch
,Distance Measurement
,Detections Transformation
,Time in Zone
,Florence-2 Model
,Model Comparison Visualization
,Mask Visualization
,Roboflow Dataset Upload
,Dynamic Crop
,Line Counter
,Detections Classes Replacement
,Polygon Visualization
,Triangle Visualization
,Bounding Rectangle
,Detections Filter
,Ellipse Visualization
,Perspective Correction
,Label Visualization
,Color Visualization
,Line Counter
,Dot Visualization
,Byte Tracker
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Segment Anything 2 Model
in version v1
has.
Bindings
-
input
images
(image
): The image to infer on.boxes
(Union[keypoint_detection_prediction
,instance_segmentation_prediction
,object_detection_prediction
]): Bounding boxes (from another model) to convert to polygons.version
(string
): Model to be used. One of hiera_large, hiera_small, hiera_tiny, hiera_b_plus.threshold
(float
): Threshold for predicted masks scores.multimask_output
(boolean
): Flag to determine whether to use sam2 internal multimask or single mask mode. For ambiguous prompts setting to True is recomended..
-
output
predictions
(instance_segmentation_prediction
): Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object.
Example JSON definition of step Segment Anything 2 Model
in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/segment_anything@v1",
"images": "$inputs.image",
"boxes": "$steps.object_detection_model.predictions",
"version": "hiera_large",
"threshold": 0.3,
"multimask_output": true
}