SAM 2.1 Hiera Large

SAM_2_1_HIERA_LARGE

Outlines the objects you point at in a picture, from a click or a box, and returns a mask for each one.

Utilitiesimage-segmentationpromptable-segmentationsam2apache-2.0Fine-tunable
SAM 2.1 Hiera Large: Utilities model on Kainguru

About SAM 2.1 Hiera Large

Capabilities

  • Click or box — a point on an object, a box around it, or both, and it outlines the object
  • Up to 16 objects — one mask per object in a single request
  • Masks in the response — each one at the picture's size, with its box and a quality score
  • Fine-tuning — teach it the outlines of your own objects with picture and mask pairs

Good to know

  • Pictures are PNG, JPEG or WebP, up to 20 MB and 40 megapixels, at least 32 pixels a side and at most 8 times longer than wide. Masks have the picture's size as displayed, scaled down to 2048 pixels on the longer side; points and boxes are in pixels of the picture.
  • One point alone can mean more than one object (a shirt, or the person wearing it), so the best of three candidate masks is returned; add points or a box to pick one.
  • Each mask comes in the JSON as COCO run-length encoding, {"size": [height, width], "counts": "..."}; pycocotools' mask.decode turns it into a 0/1 array (1 = the object). When the masks would take a response past 800 KB, as only very detailed ones do, they come at half the size or less; boxes stay in the picture's pixels.
  • Fine-tuning takes one ZIP (at most 4 GB and 10000 entries, no password) with the pictures, a black-and-white mask per object (the picture's size, white = the object) and manifest.jsonl: one {"file": ..., "mask": ...} line per mask, 4 to 2000 masks, paths relative to the manifest. A picture with several objects has a line for each.
  • Fine-tuning trains the mask decoder, prompting it with a box or a point drawn from each mask, so it learns your objects' outlines; the prompt still decides which object is outlined.

SAM 2.1 Hiera Large inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—The picture: PNG, JPEG or WebP, up to 20 MB and 40 megapixels. Masks have its size, scaled down to 2048 pixels on the longer side.
1–2048 characters · image/png, jpeg, webp
promptstextYes—JSON array, one item per object: {"box": [x0, y0, x1, y1]} and/or {"points": [[x, y], ...], "labels": [1, 0, ...]}, in pixels; label 1 = on the object, 0 = not. Up to 16 objects of up to 16 points.
2–16384 characters

Output. JSON: {"width", "height", "segments": [{"object", "score", "box", "mask"}]}, a segment per prompt in order: score = predicted mask quality, box [x0, y0, x1, y1] in pixels (null if the mask is empty), mask a COCO RLE {"size": [h, w], "counts"}.

Run SAM 2.1 Hiera Large with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=SAM_2_1_HIERA_LARGE" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "prompts": "example"
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "SAM_2_1_HIERA_LARGE",
        {
          "image": "https://example.com/input.png",
          "prompts": "example"
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune SAM 2.1 Hiera Large

You can fine-tune SAM 2.1 Hiera Large on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, no password) with pictures, one black-and-white mask per object (white = the object) and manifest.jsonl: a {"file", "mask"} line per mask, 4 to 2000. More in Good to know, in the README.

The steps are in the docs.

SAM 2.1 Hiera Large pricing

Price per image: 0.0874 credits ($0.000874). The price is shown again before every run; all prices are on the pricing page.

Licence and source

Grounded SAM 2: Utilities model on Kainguru
Utilities

Grounded SAM 2

Outlines the things you name in a picture, such as "red car, person with a helmet", with a mask and a box for each one.

Fine-tunable
Prithvi-EO 2.0 Sen1Floods11: Utilities model on Kainguru
Utilities

Prithvi-EO 2.0 Sen1Floods11

Maps water and floods from satellite images: send a Sentinel-2 GeoTIFF and get a water mask at the image's size, with…

Fine-tunable
Rembg U2-Net: Utilities model on Kainguru
Utilities

Rembg U2-Net

Fast background removal that returns the subject of a photo on a transparent background, or as a black-and-white mask.

Fine-tunable
RF-DETR Seg 2XLarge: Utilities model on Kainguru
Utilities

RF-DETR Seg 2XLarge

Finds every object of 80 everyday kinds in a picture, such as people, vehicles, animals and furniture, and outlines…

Fine-tunable
BiRefNet General: Utilities model on Kainguru
Utilities

BiRefNet General

Removes the background from a photo and returns the subject on a transparent background, or as a black-and-white mask.

Fine-tunable
Cloth Segmentation U2-Net: Utilities model on Kainguru
Utilities

Cloth Segmentation U2-Net

Finds the clothes a person wears in a photo and returns a mask for the upper body, the lower body and full-body…

Fine-tunable