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@v1to 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:
S3 Sink,Keypoint Detection Model,Email Notification,Morphological Transformation,Path Deviation,SAM 3,VLM As Detector,Clip Comparison,Qwen-VL,Twilio SMS/MMS Notification,YOLO-World Model,Time in Zone,Polygon Zone Visualization,MoonshotAI Kimi,Stitch OCR Detections,OpenAI-Compatible LLM,VLM As Detector,OpenAI,Heatmap Visualization,Keypoint Visualization,Email Notification,Seg Preview,Llama 3.2 Vision,Stability AI Image Generation,Google Vision OCR,Anthropic Claude,Camera Focus,Label Visualization,SAM 3,Instance Segmentation Model,Path Deviation,Overlap Filter,Local File Sink,Google Gemini,Motion Detection,Byte Tracker,Background Color Visualization,Mask Edge Snap,Instance Segmentation Model,Qwen 3.5 API,Google Gemini,Polygon Visualization,Moondream2,Velocity,SIFT Comparison,Grid Visualization,Detection Event Log,Florence-2 Model,Time in Zone,OCR Model,VLM As Classifier,Detections Filter,Detections Merge,Detections Stabilizer,LMM For Classification,Keypoint Detection Model,Image Preprocessing,SIFT,Roboflow Dataset Upload,Dynamic Zone,Corner Visualization,Stability AI Outpainting,Segment Anything 2 Model,Halo Visualization,Multi-Label Classification Model,Qwen3.5-VL,Time in Zone,Detections List Roll-Up,Blur Visualization,Morphological Transformation,Trace Visualization,VLM As Classifier,Stitch OCR Detections,Gaze Detection,Reference Path Visualization,Halo Visualization,Model Comparison Visualization,Dot Visualization,JSON Parser,Background Subtraction,Text Display,Detections Combine,Bounding Rectangle,ByteTrack Tracker,Absolute Static Crop,CSV Formatter,Florence-2 Model,Byte Tracker,Icon Visualization,Identify Outliers,Mask Area Measurement,Object Detection Model,Perspective Correction,SAM 3,BoT-SORT Tracker,Stability AI Inpainting,Image Convert Grayscale,Object Detection Model,Line Counter,QR Code Generator,OpenRouter,Model Monitoring Inference Aggregator,OpenAI,Llama 3.2 Vision,Image Threshold,OC-SORT Tracker,Anthropic Claude,Dynamic Crop,Detections Consensus,Contrast Enhancement,Bounding Box Visualization,Depth Estimation,Detection Offset,Keypoint Detection Model,Image Contours,EasyOCR,Relative Static Crop,Polygon Visualization,Google Gemma API,Template Matching,Qwen 3.6 API,Image Blur,Per-Class Confidence Filter,Anthropic Claude,Triangle Visualization,Object Detection Model,Roboflow Custom Metadata,OpenAI,SIFT Comparison,Slack Notification,Pixelate Visualization,Stitch Images,Single-Label Classification Model,Instance Segmentation Model,OpenAI,Image Slicer,Line Counter Visualization,Image Slicer,Cosine Similarity,Detections Classes Replacement,LMM,Roboflow Dataset Upload,Detections Transformation,Color Visualization,Google Gemini,Classification Label Visualization,Camera Focus,Camera Calibration,Detections Stitch,Byte Tracker,Ellipse Visualization,PTZ Tracking (ONVIF),Identify Changes,SORT Tracker,Mask Visualization,GLM-OCR,Crop Visualization,Circle Visualization,CogVLM,SAM2 Video Tracker,Contrast Equalization,Roboflow Vision Events,Webhook Sink,Twilio SMS Notification,MoonshotAI Kimi,Google Gemma - outputs:
Perspective Correction,BoT-SORT Tracker,Stability AI Inpainting,Path Deviation,Line Counter,Model Monitoring Inference Aggregator,Line Counter,Time in Zone,OC-SORT Tracker,Dynamic Crop,Size Measurement,Detections Consensus,Heatmap Visualization,Label Visualization,Path Deviation,Bounding Box Visualization,Overlap Filter,Detection Offset,Polygon Visualization,Byte Tracker,Background Color Visualization,Mask Edge Snap,Polygon Visualization,Velocity,Per-Class Confidence Filter,Detection Event Log,Florence-2 Model,Triangle Visualization,Time in Zone,Roboflow Custom Metadata,Detections Filter,Detections Merge,Pixelate Visualization,Detections Stabilizer,Roboflow Dataset Upload,Detections Classes Replacement,Dynamic Zone,Segment Anything 2 Model,Corner Visualization,Halo Visualization,Roboflow Dataset Upload,Detections Transformation,Time in Zone,Color Visualization,Blur Visualization,Detections List Roll-Up,Camera Focus,Distance Measurement,Trace Visualization,Detections Stitch,Halo Visualization,Byte Tracker,Ellipse Visualization,Model Comparison Visualization,Dot Visualization,PTZ Tracking (ONVIF),SORT Tracker,Mask Visualization,Crop Visualization,Circle Visualization,Detections Combine,Bounding Rectangle,ByteTrack Tracker,SAM2 Video Tracker,Florence-2 Model,Roboflow Vision Events,Byte Tracker,Icon Visualization,Mask Area Measurement
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[instance_segmentation_prediction,object_detection_prediction,keypoint_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
}