Load Vit Matte Model (mtb)
Load a matting model for real soft edges
- torch_script
This loads a ViTMatte model - a proper image matting network - for MTB's matting pipeline. It's the loader half: it fetches the weights and hands them downstream to the node that actually does the matting. On its own it produces no image.
Here's why you'd bother, and it's the single most misunderstood point in background removal. A segmentation model (rembg, u2net, even BiRefNet in its base mode) labels every pixel foreground or background - a hard yes/no. That's structurally wrong for anything genuinely see-through: a veil, a wine glass, smoke, motion blur, wispy hair. Those pixels are partly transparent, and a yes/no mask can't represent "40% opaque." Matting can. ViTMatte predicts a fractional alpha per pixel, so a cutout that looks clean on a grey preview but falls apart against a colored background - the classic segmentation failure - is exactly what matting fixes. If your cutouts keep getting an ugly halo on hard material, this is the tool.
How it works
ViTMatte is a Vision-Transformer-based matting model. Given an image and a trimap (more on that below), it estimates the true alpha channel, including the soft in-between values. It's the heavier, higher-quality path - you reach for it when segmentation isn't good enough, not as your everyday cutout.
The inputs that matter
kind- which trained model to load: Composition-1K or Distinctions-646. These are two different matting datasets. Composition-1K (Adobe's) is the general-purpose default; Distinctions-646 was trained on a wider set of distinct objects. If one gives you a worse edge on your particular subject, swap to the other - they genuinely differ per image, and trying both is cheap.autodownload(default on) - fetches the weights automatically the first time. Leave it on unless you're managing model files by hand.
The single output is torch_script (a VITMATTE_MODEL) - wire it into MTB's matting-apply node, which is where you feed the actual image and trimap.
How to install it
ComfyUI Manager: search MTB Nodes (comfy_mtb), install, restart. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/melMass/comfy_mtb, then restart. If the node doesn't appear, MTB's dependency panel at http://127.0.0.1:8188/mtb installs whatever it's missing.
Common issues
The thing nobody tells beginners: ViTMatte needs a trimap, not just an image. A trimap is a three-region map - definite foreground (white), definite background (black), and an "unknown" band (grey) around the edges where the model does its soft-alpha magic. You generate it from a coarse mask by eroding it for the sure-foreground and dilating it for the sure-background, leaving a grey ring in between. Feed a rubbish trimap - too thin an unknown band, or no unknown region at all - and the output is rubbish. Most of the quality lives in the trimap, not the model choice.
On downloads, autodownload handles the weights, but as with any model fetch it needs internet on first run and can be blocked by an overzealous antivirus. And keep expectations calibrated: this is the right tool for hair, veils, glass and smoke, and overkill for a solid subject on a plain background - for that, plain rembg is faster and just as good.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| kind | COMBO | 2 options: Composition-1K, Distinctions-646 | |
| autodownload | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| torch_script | VITMATTE_MODEL | — |