Segment Anything 2
Segment objects in an image.
The default Gateway used in this guide is the public
Livepeer.cloud Gateway. It is free to use but
not intended for production-ready applications. For production-ready
applications, consider using the Livepeer Studio
Gateway, which requires an API token. Alternatively, you can set up your own
Gateway node or partner with one via the ai-video
channel on
Discord.
Please note that the exact parameters, default values, and responses may vary between models. For more information on model-specific parameters, please refer to the respective model documentation available in the segment-anything-2 pipeline. Not all parameters might be available for a given model.
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
Image to segment.
Hugging Face model ID used for image generation.
Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels.
Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point.
A length 4 array given as a box prompt to the model, in XYXY format.
A low-resolution mask input to the model, typically from a previous prediction iteration, with the form 1xHxW (H=W=256 for SAM).
If true, the model will return three masks for ambiguous input prompts, often producing better masks than a single prediction.
If true, returns un-thresholded mask logits instead of a binary mask.
If true, the point coordinates will be normalized to the range [0,1], with point_coords expected to be with respect to image dimensions.
Was this page helpful?