image_url or one video_url; no text-only input
and no document_url. A text prompt names what to segment, so segment on an
image and track on a video both take method_params.prompt.
segment is the default method. Each instance returns a normalized bounding
box, a score, its area, and an instance_id. The pixels are not on the
item: every instance shares one label map on the
container.
Output by method
Method parameters
Unlike the models that decode a
video_url natively, facebook/sam3.1 reads
its sampling out of method_params, not from a top-level video_fps.
Request
Response
- Text mode
- JSON mode
- Tracking a video
A single image returns the json block alone, with no wrapper:
bbox_xywh and area are normalized against the source frame. The pixels live
in the label map: one 8-bit grayscale PNG where a pixel’s value is the item’s
instance_id on an image, or its track_id on a video.
0 is background, so ids start at 1 and run to 255, which is also
the most instances one map can carry. Test pixel == n to cut out instance n,
or pixel != 0 for the whole foreground. One decode gives every instance, and
area and score sit on the items so a filter never has to decode at all.
Where two instances overlap the pixel goes to the higher score, so each item’s
area, box and outline describe what is actually visible in the map.
video_fps, video_nframes and video_duration describe the source clip.
frames is what was actually sampled, listed in frame_id order and including
frames where nothing was found.
A prompt that matches nothing is not an error. The call succeeds with an empty
items array.