MODNet Video Matting

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 empty-background shot; returns the matte or the people over a flat colour.

Video Editingvideo-mattingportraitbackground-removalalpha-matteapache-2.0Fine-tunable
MODNet Video Matting: Video Editing model on Kainguru

About MODNet Video Matting

Capabilities

  • No setup — no green screen and no picture of the empty background needed
  • Soft edges — an alpha matte with partial transparency at hair and other fine edges
  • Matte or composite — the matte as a grey video, or the people over a flat colour to key out or cover
  • Fine-tunable — train it on your own clips and their mattes

Good to know

  • Made for people: portraits, webcam and half-body shots. For objects and products, a general segmentation model works better.
  • Videos are MP4, MOV, WebM or MKV, at most 256 MB, 600 frames and 2,073,600 pixels a frame (1920 x 1080). H.264 holds no transparency, so a result is the matte (white = person) or the people over a flat colour; it has no sound.
  • The result is an SDR video at a constant frame rate: a variable-frame-rate video is re-timed evenly at its average rate, and HDR (HLG or PQ) colours are not tone-mapped, so they look flatter than in an HDR player.
  • Each frame is matted on its own; Reduce flicker (on by default) smooths a pixel that jumps for one frame while the frames around it agree.
  • Fine-tuning takes one ZIP (at most 4 GB, 128 MB a clip, no password) with 2 to 100 clips and a manifest.jsonl holding one {"video": "clips/a.mp4", "matte": "mattes/a.mp4"} line per clip, paths relative to the manifest. A matte is a grey video of the clip's size and length: white for the person, black for the background, grey where both mix.
  • Training works on random frames of the first 48 frames of each clip, letterboxed to 512 x 512 and mirrored half of the time; it stops after the steps you ask for or after 9 hours, keeping what it has learned.

Attribution

MODNet by Zhanghan Ke, Jiayu Sun, Kaican Li, Qiong Yan and Rynson W.H. Lau, released under the Apache License 2.0.

MODNet Video Matting inputs and output

NameTypeRequiredDefaultDetails
videofileYes—The video of people: MP4, MOV, WebM or MKV, at most 256 MB, 600 frames and 2,073,600 pixels a frame. The result has no sound.
1–2048 characters · video/mp4, quicktime, webm, x-matroska
outputtextNocompositecomposite: the people over a flat backdrop colour; matte: the alpha matte as a grey video, white = person.
Allowed: composite, matte
smoothbooleanNotrueSmooths a matte pixel that jumps for one frame while the frames around it agree.
backdroptextNogreenThe flat colour behind the people in a composite.
Allowed: green, blue, white, black, gray

Output. Returns MP4 video: The people over a flat colour, or their alpha matte as a grey video: an H.264 MP4 without sound, the input's size and frame rate.

Run MODNet Video Matting 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=MODNET_VIDEO_MATTING" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "video": "https://example.com/input.png",
    "backdrop": "green",
    "output": "composite",
    "smooth": true
  },
  "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(
        "MODNET_VIDEO_MATTING",
        {
          "video": "https://example.com/input.png",
          "backdrop": "green",
          "output": "composite",
          "smooth": True
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune MODNet Video Matting

You can fine-tune MODNet Video Matting on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, 128 MB a clip, no password) with 2 to 100 clips, a grey matte video for each, and manifest.jsonl with one line per clip: {"video", "matte"}. More: Good to know, in the README.

The steps are in the docs.

MODNet Video Matting 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

Background Matting v2: Video Editing model on Kainguru
Video Editing

Background Matting v2

Cuts a person out of video precisely, hair included, when you also give a picture of the empty background from the…

Fine-tunable
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
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
SAM 2.1 Video: Video Editing model on Kainguru
Video Editing

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…

Fine-tunable