Nodes/ComfyUI-RMBG/SDMatte Matting (RMBG)
ComfyUI Node Runs on cloud

SDMatte Matting (RMBG)

SDMatte Matting (RMBG)

By 1038lab·Created 2 years ago·Updated 7 days ago· 2,051
SDMatte Matting (RMBG)
  • image
  • mask
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
modelSDMatte
deviceAuto
process_res1024
transparent_objecttrue
mask_refinetrue
sensitivity0.9
mask_blur0
mask_offset0
invert_outputfalse
backgroundAlpha

SDMatte is the node you reach for when a normal background remover keeps failing on the same thing: hair, glass, veils, smoke, motion blur - anything that's genuinely semi-transparent. That's the whole reason it exists. Everything else in this pack that removes a background is a segmentation model: it labels each pixel foreground or background, full stop. That's exactly the wrong tool for a wisp of hair or the edge of a wine glass, because those pixels are physically half-transparent and a hard yes/no label can't say so. Matting predicts fractional alpha instead. So a cutout that looks perfect against the grey preview but turns into a hard-edged sticker the moment you drop it on a colored background - that's a segmentation model doing a matting job, and SDMatte is the fix.

The mechanism is a little unusual: SDMatte (from vivo Camera Research) repurposes a diffusion backbone for the matting task, which is why the config it downloads looks like a Stable Diffusion model - scheduler, text encoder, unet, vae. You don't prompt it; it uses that machinery to reason about soft edges. Practically, it takes an image and optionally a rough mask, and returns a clean alpha matte.

The inputs worth setting: model picks SDMatte (standard) or SDMatte_plus (the heavier, higher-quality variant). process_res is your quality/VRAM dial (256–2048, default 1024). The interesting optional inputs are mask and transparent_object. Feed a rough mask in - say, from the RMBG node or a Segment node - and SDMatte refines it into a proper matte; that's the intended pipeline, matting as a second stage that cleans up a coarse cutout. transparent_object (on by default) tells it to expect see-through material, which is the case you'd be using this node for anyway. sensitivity (0.1–1, default 0.9) tunes how much it trusts the input, and mask_refine does an extra cleanup pass. The usual mask_blur, mask_offset, invert_output, background, and background_color are all here too. device lets you force CPU or GPU. Outputs are the standard IMAGE (matted result), MASK (the alpha matte), and MASK_IMAGE (mask as a viewable picture) - and here the MASK is the valuable output, because it carries the soft edges.

Install is the pack routine: "Comfyui-RMBG" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt and restart. SDMatte's weights auto-download on first run into ComfyUI/models/RMBG/SDMatte/ - and because it's a diffusion-style model with several component folders (scheduler, text_encoder, tokenizer, unet, vae), that first download is chunkier than the lightweight segmentation models. If your network blocks the auto-download, the README tells you to drop SDMatte.safetensors (or SDMatte_plus.safetensors) into that folder manually and mirror the component subfolders from the Hugging Face repo.

Where it fits: don't use SDMatte as your everyday background remover. For a solid subject on a clean background it's overkill and slower than it needs to be - RMBG or BiRefNet-general will do that faster. Save it for the specific failure mode of "the edge looks fake on a real background." The best results usually come from chaining: get a fast coarse cutout from RMBG or a Segment node, pipe that mask into SDMatte's mask input, and let it do the soft-edge reconstruction. If you own the generation and you're on SD 1.5 or SDXL, native transparent generation (LayerDiffusion) still beats any matting model because the alpha was never guessed - but that's a narrow set of pipelines, and for cutting up an image you already have, SDMatte is the transparency specialist in this pack.

Category🧪AILab/🧽RMBG

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
modelCOMBOSDMatteSDMatte model variant: Standard or Plus version
deviceCOMBOAutoAuto: smart detection, CPU: force CPU, GPU: force GPU
process_resINT1024256–2048Processing resolution: higher = better quality but slower
maskoptMASKMask: White=foreground, Black=background. If omitted and image has alpha, alpha will be used.
transparent_objectoptBOOLEANtrueWhether input image contains transparent objects
mask_refineoptBOOLEANtrueEnable mask refinement using mask constraints
sensitivityoptFLOAT0.90.1–1Sensitivity for mask constraint (0.1-1.0): higher = more strict
mask_bluroptINT00–64Blur mask edges (0 = disabled)
mask_offsetoptINT0-64–64Expand/shrink mask (positive = expand)
invert_outputoptBOOLEANfalseInvert the mask output
backgroundoptCOMBOAlphaBackground type for output
background_coloroptCOLORCODE#222222Background color (when not Alpha)

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE