Nodes/ComfyUI-RMBG/MultiMatte (RMBG)
ComfyUI Node Runs on cloud

MultiMatte (RMBG)

Type \"flowing hair\", get soft alpha — MultiMatte is the promptable matting node

By 1038lab·Created 2 years ago·Updated 11 days ago· 2,264
MultiMatte (RMBG)
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
◄modelMultiMatte-bf16 (1.57GB)►
◄prompt►
◄mask_blur0►
◄mask_offset0►
◄invert_outputfalse►
◄refine_foregroundtrue►
◄unload_modelfalse►
◄backgroundAlpha►

Most background removers answer one question: where does the subject end? That's a segmentation question, and segmentation hands you a hard edge. Hair doesn't have a hard edge. Neither does a wine glass, a veil, or a cat's ear fur. What you actually want there is matting - a fractional alpha value per pixel, so a wisp of hair can be 30% opaque instead of all-or-nothing.

MultiMatte (RMBG) is the node in ComfyUI-RMBG that does matting and lets you point it at things. Type woman in red dress and it extracts her with soft edges. Leave the prompt blank and it grabs the main subject. That combination - text-grounded target selection plus continuous alpha - is the reason to reach for this one instead of a plain BiRefNet cutout.

What it actually does under the hood

It's SAM 3, repackaged. The node bundles SAM 3's model code inside the custom node folder and loads a checkpoint (MultiMatte-bf16, converted from the Hugging Friendly state dict into SAM 3's internal layout) from ComfyUI/models/RMBG/MultiMatte/. On each run it:

  1. Feeds your image through the SAM 3 vision backbone at a fixed 1008×1008.
  2. Encodes your prompt with the text backbone and runs grounding - the full-image variant, with a dummy geometric prompt, so you get a mask rather than boxes.
  3. Takes the semantic_seg logits, bilinearly upsamples them to your original resolution, and applies a sigmoid. That sigmoid is where the soft alpha comes from: logits near zero become half-transparent pixels instead of being thresholded away.
  4. Optionally cleans the edge colour (see refine_foreground below), then composites or cuts out.

Because the model runs at 1008×1008 and the mask is upsampled back, you keep your original output resolution, but the decision about each pixel was made at roughly one megapixel. Fine for a portrait; the thing to remember when a tiny distant object comes back mushy.

Inputs that matter, and the outputs

Only image is required. It takes a batch and loops over it, so a folder of frames is fine.

The three you'll actually touch:

  • prompt - English, short, descriptive. glass bottle, wedding veil, cat fur, person. Empty means the node substitutes the internal string the main foreground subject, so blank isn't "no target", it's auto-subject.
  • model - MultiMatte-bf16 (1.57GB) is the default and the right call. MultiMatte-fp8 (0.84GB) if you're tight on VRAM, MultiMatte-fp32 (3.13GB) if you enjoy waiting.
  • refine_foreground - on by default here, and it's the edge-colour cleanup. It estimates the foreground colour by averaging unmixed nearby pixels and re-blends, so hair strands stop carrying a dark rim from the old background.

Then mask_blur (Gaussian radius, 0–64) and mask_offset (expand/shrink, -64 to 64) if the edge needs nudging, invert_output, unload_model to drop the weights right after the run, and background - Alpha for a transparent cutout, or Color plus a hex background_color to composite against a flat field.

Outputs: IMAGE (RGBA when you chose Alpha), MASK (the actual fractional alpha - wire it into a compositor, a latent mask, or a Mask Blur chain), and MASK_IMAGE, which is the same mask expanded to three channels so you can preview it or feed it to nodes that want an image, not a mask.

Installing it

Via ComfyUI Manager: search Comfyui-RMBG and install. Or the manual way, then restart:

cd ComfyUI/custom_nodes
git clone https://github.com/1038lab/ComfyUI-RMBG
cd ComfyUI-RMBG
../../python_embeded/python -m pip install -r requirements.txt   # or your env's python

The checkpoint auto-downloads on first run (1.57GB) into models/RMBG/MultiMatte/. You can also grab it from 1038lab/MultiMatte on Hugging Face and drop it in yourself - which is what I'd do on a metered connection, since the download happens inside a node execution and a timeout there is annoying to debug.

Where people get burned

Prompts in English. The grounding text encoder was trained on English captions; other languages degrade into luck.

refine_foreground only fires in Alpha mode. The code checks background == "Alpha" and refine_foreground - switch to Color and the refinement is silently skipped. If your flat-background export has an ugly fringe the transparent one doesn't, that's why.

Big mask_offset values are slow. It's implemented as repeated max/min filter passes on a full-resolution mask, one pass per pixel of offset. mask_offset: 64 is 64 passes over a 4K mask. Keep it single digits.

The requirements file is a dependency minefield. It pins onnxruntime and onnxruntime-gpu, plus protobuf<6.0.0, and pulls transparent-background, groundingdino-py and segment-anything you may never use for this node. If Windows crashes right after installing, set PYTHONUTF8=1 and reinstall, per the README. Worth knowing: the pack is GPL-3.0, unlike most of the models it wraps (MIT), so don't build a shipped product around it without reading that.

One thing in its favour versus the pack's own SAM3 segmentation node: no Triton. MultiMatte's inference path is plain PyTorch, so the Windows Triton build that trips people up on SAM3 doesn't apply here.

Category🧪AILab/🧽RMBG

Inputs (10)

NameTypeDefaultDescription
imageIMAGEInput image batch for promptable alpha matting.
modeloptCOMBOMultiMatte-bf16 (1.57GB)Select model precision: BF16 (1.57GB, recommended), FP8 (0.84GB, low VRAM), or FP32 (3.13GB, full precision).
promptoptSTRINGDescribe the target to matte in English (e.g. 'person', 'woman in red dress', 'flowing hair', 'glass cup', 'wedding veil', 'cat fur'). Leave empty to automatically matte the main foreground subject.
mask_bluroptINT00–64Gaussian blur radius for softening mask edges.
mask_offsetoptINT0-64–64Expand (positive) or shrink (negative) the mask boundary in pixels.
invert_outputoptBOOLEANfalseInvert the output mask.
refine_foregroundoptBOOLEANtrueSub-pixel foreground boundary refinement for fine hairs and semi-transparent edges.
unload_modeloptBOOLEANfalseUnload model weights from VRAM immediately after execution.
backgroundoptCOMBOAlphaOutput format: Alpha for transparent PNG, or Color to composite against background.
background_coloroptCOLORCODE#222222Hex background color used when background mode is set to Color.

Outputs (3)

NameTypeDescription
IMAGEIMAGE—
MASKMASK—
MASK_IMAGEIMAGE—