跳转到主要内容
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>"
}

授权

Authorization
string
header
必填

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

请求体

multipart/form-data
image
file
必填

Image to segment.

model_id
string
默认值:""

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
默认值:true

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

return_logits
boolean
默认值:true

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

normalize_coords
boolean
默认值: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.

响应

Successful Response

Response model for object segmentation.

masks
string
必填

The generated masks.

scores
string
必填

The model's confidence scores for each generated mask.

logits
string
必填

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

Last modified on March 1, 2026