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.
Runtime compatibility¶
-
hard— runtimeself_hosted_cpu; executionlocal - Requires a GPU; run_locally() loads a model that needs CUDA.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Segment Anything 2 Model in version v1.
- inputs:
VLM As Classifier,Line Counter,MoonshotAI Kimi,Stability AI Image Generation,Trace Visualization,Path Deviation,Anthropic Claude,Per-Class Confidence Filter,Icon Visualization,SIFT Comparison,Morphological Transformation,Color Visualization,LMM For Classification,Perspective Correction,Corner Visualization,Roboflow Custom Metadata,Detections Merge,Halo Visualization,Dynamic Zone,Keypoint Detection Model,Qwen-VL,JSON Parser,Email Notification,Halo Visualization,Object Detection Model,Google Gemma,Background Color Visualization,Ellipse Visualization,Email Notification,Twilio SMS/MMS Notification,Text Display,Polygon Visualization,Crop Visualization,Absolute Static Crop,Image Preprocessing,Template Matching,Model Monitoring Inference Aggregator,Relative Static Crop,OpenRouter,OpenAI,VLM As Detector,Florence-2 Model,OCR Model,Heatmap Visualization,Motion Detection,OpenAI,Detections Filter,Blur Visualization,Depth Estimation,Instance Segmentation Model,Stability AI Outpainting,Anthropic Claude,YOLO-World Model,Google Gemini,Clip Comparison,Google Gemini,Background Subtraction,Keypoint Visualization,CSV Formatter,Webhook Sink,Byte Tracker,Stitch Images,Florence-2 Model,Current Time,Detections List Roll-Up,Contrast Equalization,Mask Edge Snap,OpenAI,Moondream2,VLM As Detector,Google Gemini,Triangle Visualization,Slack Notification,Overlap Filter,Time in Zone,Detections Stabilizer,SIFT,Local File Sink,Cosine Similarity,Image Contours,Keypoint Detection Model,VLM As Classifier,GLM-OCR,Roboflow Asset Library Attributes,Image Slicer,Polygon Zone Visualization,Contrast Enhancement,Time in Zone,Google Gemma API,Stitch OCR Detections,Image Threshold,Line Counter Visualization,Camera Calibration,QR Code Generator,Detection Offset,ByteTrack Tracker,Detection Event Log,Detections Transformation,S3 Sink,Microsoft SQL Server Sink,Mask Area Measurement,Google Vision OCR,Twilio SMS Notification,Image Blur,Detections Combine,Morphological Transformation,Camera Focus,Roboflow Vision Events,Stability AI Inpainting,PTZ Tracking (ONVIF),Classification Label Visualization,Bounding Rectangle,SAM2 Video Tracker,Stitch OCR Detections,Event Writer,Grid Visualization,Qwen3.5-VL,Mask Visualization,Byte Tracker,Llama 3.2 Vision,Reference Path Visualization,Image Slicer,Label Visualization,Velocity,Identify Outliers,Byte Tracker,SIFT Comparison,OPC UA Writer Sink,Dot Visualization,Identify Changes,Dynamic Crop,Detections Stitch,Circle Visualization,Path Deviation,BoT-SORT Tracker,SAM3 Video Tracker,Camera Focus,Llama 3.2 Vision,Gaze Detection,Segment Anything 2 Model,OpenAI-Compatible LLM,MoonshotAI Kimi,Single-Label Classification Model,CogVLM,Object Detection Model,SAM 3 Interactive,Qwen 3.6 API,Detections Consensus,Bounding Box Visualization,Multi-Label Classification Model,LMM,SAM 3,OpenAI,PLC Reader,Image Convert Grayscale,Instance Segmentation Model,Roboflow Visual Search,EasyOCR,Roboflow Dataset Upload,SAM 3,Detections Classes Replacement,Instance Segmentation Model,Pixelate Visualization,Keypoint Detection Model,Instance Segmentation Model,SORT Tracker,Roboflow Dataset Upload,PLC Writer,Track Class Lock,Qwen 3.5 API,Object Detection Model,Anthropic Claude,Time in Zone,MQTT Writer,Polygon Visualization,OC-SORT Tracker,SAM 3,Model Comparison Visualization,Seg Preview - outputs:
Line Counter,Time in Zone,Path Deviation,Trace Visualization,Distance Measurement,Detection Offset,ByteTrack Tracker,Detection Event Log,Per-Class Confidence Filter,Icon Visualization,Detections Transformation,Color Visualization,Perspective Correction,Corner Visualization,Mask Area Measurement,Roboflow Custom Metadata,Detections Merge,Halo Visualization,Dynamic Zone,Detections Combine,Roboflow Vision Events,Size Measurement,Halo Visualization,Stability AI Inpainting,PTZ Tracking (ONVIF),Bounding Rectangle,SAM2 Video Tracker,Event Writer,Mask Visualization,Byte Tracker,Background Color Visualization,Ellipse Visualization,Velocity,Label Visualization,Byte Tracker,Dot Visualization,Polygon Visualization,Crop Visualization,Dynamic Crop,Path Deviation,Circle Visualization,Detections Stitch,BoT-SORT Tracker,Model Monitoring Inference Aggregator,Camera Focus,Segment Anything 2 Model,Florence-2 Model,Heatmap Visualization,Detections Filter,Overlap Analysis,Blur Visualization,SAM 3 Interactive,Detections Consensus,Byte Tracker,Bounding Box Visualization,Florence-2 Model,Detections List Roll-Up,Mask Edge Snap,Line Counter,Triangle Visualization,Overlap Filter,Roboflow Dataset Upload,Time in Zone,Detections Classes Replacement,Pixelate Visualization,Roboflow Dataset Upload,Detections Stabilizer,SORT Tracker,Track Class Lock,Time in Zone,Polygon Visualization,OC-SORT Tracker,Model Comparison Visualization
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,object_detection_prediction,instance_segmentation_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
}