Saltar al contenido principal
POST
/
segment-anything-2
Segment Anything 2
curl --request POST \
  --url https://dream-gateway.livepeer.cloud/segment-anything-2 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form image='@example-file' \
  --form model_id= \
  --form 'point_coords=<string>' \
  --form 'point_labels=<string>' \
  --form 'box=<string>' \
  --form 'mask_input=<string>' \
  --form multimask_output=true \
  --form return_logits=true \
  --form normalize_coords=true
{
  "masks": "<string>",
  "scores": "<string>",
  "logits": "<string>"
}

Autorizaciones

Authorization
string
header
requerido

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Cuerpo

multipart/form-data
image
file
requerido

Image to segment.

model_id
string
predeterminado:""

Hugging Face model ID used for image generation.

point_coords
string

Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels.

point_labels
string

Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point.

box
string

A length 4 array given as a box prompt to the model, in XYXY format.

mask_input
string

A low-resolution mask input to the model, typically from a previous prediction iteration, with the form 1xHxW (H=W=256 for SAM).

multimask_output
boolean
predeterminado:true

If true, the model will return three masks for ambiguous input prompts, often producing better masks than a single prediction.

return_logits
boolean
predeterminado:true

If true, returns un-thresholded mask logits instead of a binary mask.

normalize_coords
boolean
predeterminado:true

If true, the point coordinates will be normalized to the range [0,1], with point_coords expected to be with respect to image dimensions.

Respuesta

Successful Response

Response model for object segmentation.

masks
string
requerido

The generated masks.

scores
string
requerido

The model's confidence scores for each generated mask.

logits
string
requerido

The raw, unnormalized predictions (logits) for the masks.

Last modified on March 1, 2026