Segment Anything 2 Model
Convert bounding boxes to polygons, or run SAM2 on an entire image to generate a mask.
Last updated
Was this helpful?
Convert bounding boxes to polygons, or run SAM2 on an entire image to generate a mask.
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.
Use the following identifier in step "type" field: roboflow_core/segment_anything@v1 to add the block as a step in your workflow.
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.
hard - runtime self_hosted_cpu; execution local : Requires a GPU; run_locally() loads a model that needs CUDA.
The available connections depend on its binding kinds. Check what binding kinds Segment Anything 2 Model in version v1 has.
input
images (image): The image to infer on..
boxes (Union[instance_segmentation_prediction, keypoint_detection_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.
Last updated
Was this helpful?
Was this helpful?
{
"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
}