apyhub
ARTIFICIAL INTELLIGENCE · IMAGE PROCESSING

Image Segmentation API

What it does

Image Segmentation detects and separates objects in an image, then returns a mask for each detected region. Send a JPEG, PNG, or WebP file and you get object masks back in a structured response you can use for editing, analysis, or downstream computer vision workflows.

The request body accepts a binary file and an optional max_masks limit from 1 to 200, with a default of 50. That makes it easy to control how many segments you want from a single image without changing the source image itself.

The response includes mask_count, the original image_size (h and w), and a masks array. Each mask can include area, bbox as [x, y, w, h], mask_rle with run-length encoded data, plus predicted_iou and stability_score for quality assessment.

Use Image Segmentation when you need to isolate foreground objects, prepare regions for annotation, measure object coverage, or feed segmented regions into an image pipeline. It’s a practical fit for product photography, scene understanding, and automated image analysis.

POST
Automatically detect and segment all objects in an image
http://localhost:8080/dosvak/auto-segmentation
QUICKSTARTGUIDE

Quickstart

Upload one image to get its segmentation masks back.

curl -X POST "http://localhost:8080/dosvak/auto-segmentation" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/image.jpg"

What you'll get back

Returns a JSON object with masks, image_size, and mask_count fields.

  • masks is an array of mask objects. Each mask can include area (integer), bbox ([x, y, w, h] integer array), mask_rle (an object with size, order, and counts), predicted_iou (number), and stability_score (number).
  • image_size is an object with h and w integers, and mask_count is an integer.
{
  "masks": [],
  "image_size": {
    "h": 0,
    "w": 0
  },
  "mask_count": 0
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
Image file (JPEG/PNG/WebP, max 20 MB)

About this endpoint

What it does

Uploads an image and automatically segments the objects it contains. The response returns the detected masks along with basic metadata about each mask and the source image size.

Request Body

ParameterTypeMandatoryDescription
fileStringYesImage file (JPEG/PNG/WebP, max 20 MB).
max_masksIntegerNoMaximum number of masks to return. Default: 50. Minimum: 1. Maximum: 200.

Response

Returns a JSON object with masks as an array of mask objects, image_size as an object with the image dimensions, and mask_count as an integer. Each mask object includes area, bounding box, RLE-encoded mask data, and scoring fields.

ParameterTypeMandatoryDescription
masksObject ArrayNoArray of detected mask objects. Each item includes:<br>area (integer)<br>bbox (integer array, [x, y, w, h])<br>mask_rle (object, run-length encoded boolean mask)<br>predicted_iou (number)<br>stability_score (number)
masks[].areaIntegerNoMask area.
masks[].bboxString ArrayNoBounding box as an integer array in the form [x, y, w, h].
masks[].mask_rleObjectNoRun-length encoded boolean mask. Includes nested fields size, order, and counts.
masks[].mask_rle.sizeString ArrayNoMask size as an integer array in the form [height, width].
masks[].mask_rle.orderENUMNoMask run order. Allowed value: F.
masks[].mask_rle.countsString ArrayNoRun lengths in column-major order.
masks[].predicted_iouNumberNoPredicted intersection-over-union score.
masks[].stability_scoreNumberNoStability score.
image_sizeObjectNoImage dimensions. Includes h and w.
image_size.hIntegerNoImage height.
image_size.wIntegerNoImage width.
mask_countIntegerNoNumber of masks returned.

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.