SAM 2.1 Video

SAM_2_1_VIDEO

Marks objects on one frame of a video with a click or a box, follows them through the whole clip and returns a mask video, one grey level per object.

Video Editingvideo-segmentationobject-trackingpromptable-segmentationsam2apache-2.0Fine-tunable
SAM 2.1 Video: Video Editing model on Kainguru

About SAM 2.1 Video

Capabilities

  • Click or box — mark up to 8 objects on any frame; they are followed forward to the end and back to the start
  • Mask video out — one H.264 video at the clip's frame rate, each object at its own grey level
  • Boxes per frame — the result lists each object's box on every frame it appears in
  • Fine-tuning — teach the mask decoder the outlines of your own objects from clips and their mask videos

Good to know

  • Clips are MP4, MOV, WebM or MKV, up to 200 MB, 300 frames and 3840 pixels a side. Objects are tracked at up to 1280 pixels on the longer side, and the mask video comes back at that size.
  • Points and boxes are in pixels of the clip as displayed, given for one frame (the first unless you choose another): each object is a box and/or points with labels, 1 on the object and 0 off it. From a later frame, objects are followed to the end and then back to the start.
  • The mask video is black where nothing is tracked and gives object k of n the grey level 255 * k / n (255 for a single object); cut it halfway between levels to get each object's mask back. The result also lists each object's level and its box on every frame.
  • You pay for the frames of the clip, whatever the number of objects.
  • Fine-tuning takes one ZIP (at most 4 GB, no password) with 2 to 200 clips and manifest.jsonl, one {"video": ..., "mask": ..., "levels": [...]} line per clip, paths relative to it. The mask video has the clip's frame count and size; it is black and shows each object at one grey level, 255 for a single object or the listed levels (up to 8) for several.
  • Fine-tuning trains the mask decoder on single frames, prompting it with a box or a point drawn from each mask; tracking stays the base model's. It stops after 5000 steps or 9 hours, whichever comes first, and keeps what it has learned.

Attribution

SAM 2.1 (facebook/sam2.1-hiera-large) by Meta, released under the Apache License 2.0.

SAM 2.1 Video inputs and output

NameTypeRequiredDefaultDetails
videofileYes—The clip: MP4, MOV, WebM or MKV, at most 200 MB, 300 frames and 3840 pixels a side. Masks come back at its size, scaled to 1280 pixels on the longer side.
1–2048 characters · video/mp4, quicktime, webm, x-matroska
promptstextYes—JSON array, one item per object on the chosen frame: {"box": [x0, y0, x1, y1]} and/or {"points": [[x, y], ...], "labels": [1, 0, ...]} in pixels; label 1 = on the object, 0 = not. Up to 8 objects of up to 16 points.
2–16384 characters
frameintegerNo0The frame the objects are marked on (0 = the first). They are tracked from there to the end and back to the start.
0–299

Output. Returns MP4 video: The mask video (H.264 MP4, the clip's frame rate): black where nothing is tracked, each object its own grey level, 255 * k / n for object k of n. The result also lists each object's level and its box on every frame.

Run SAM 2.1 Video 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_VIDEO" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "prompts": "example",
    "video": "https://example.com/input.png",
    "frame": 0
  },
  "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_VIDEO",
        {
          "prompts": "example",
          "video": "https://example.com/input.png",
          "frame": 0
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune SAM 2.1 Video

You can fine-tune SAM 2.1 Video on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, no password) with 2 to 200 clips, a mask video for each (black; the objects at their grey levels) and manifest.jsonl: a {"video", "mask", "levels"} line per clip. More in Good to know, in the README.

The steps are in the docs.

SAM 2.1 Video pricing

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

Licence and source

Wan 2.1 VACE 1.3B: Video Editing model on Kainguru
Video Editing

Wan 2.1 VACE 1.3B

Video-editing model (Wan 2.1 VACE, 1.3B): follows a control clip, redoes a masked area or the end of a clip, or puts…

Fine-tunable
FILM: Video Editing model on Kainguru
Video Editing

FILM

Makes slow motion and higher frame rates by painting the frames between two frames, even when things move far between…

Fine-tunable
MODNet Video Matting: Video Editing model on Kainguru
Video Editing

MODNet Video Matting

Cuts people out of video with a soft alpha matte that keeps hair and fine edges, with no green screen and no…

Fine-tunable
RealBasicVSR: Video Editing model on Kainguru
Video Editing

RealBasicVSR

Enlarges a real-world video 4 times, looking across frames so detail stays steady and flicker is lower than with…

Fine-tunable
ReCamMaster: Video Editing model on Kainguru
Video Editing

ReCamMaster

Video-editing model (ReCamMaster on Wan 2.1, 1.3B) that re-renders a clip along a new camera path: pan, tilt, zoom…

Fine-tunable
SVOR: Video Editing model on Kainguru
Video Editing

SVOR

Removes objects from a video. Send a clip and a mask video of what to remove, and it fills the area in, shadows and…

Fine-tunable