Nodes/ComfyUI-RMBG/Remove Background (RMBG)
ComfyUI Node Runs on cloud

Remove Background (RMBG)

RMBG (Remove Background)

By 1038lab·Created 2 years ago·Updated 12 days ago· 2,057
Remove Background (RMBG)
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
model
sensitivity1.00
process_res1024
mask_blur0
mask_offset0
invert_outputfalse
refine_foregroundfalse
backgroundAlpha

This is the node most people install ComfyUI-RMBG for in the first place: one-click background removal. You feed it an image, pick a model, and it hands you back a transparent cutout plus the mask it used. No prompt, no clicking points, no manual masking. For product shots, character cutouts, and anything you want to composite onto a new background, this is the "just make the background go away" button.

Under the hood it's a menu of four salient-object models rather than one. The model dropdown gives you RMBG-2.0 (BRIA's model, built on the BiRefNet architecture, the strongest all-rounder here), INSPYRENET (fast, especially good on portraits and hair), BEN, and BEN2 (a decent speed/accuracy balance for batches). They all do the same job - find the subject, cut everything else - but they fail differently. Background removal is the most commoditized operation in the whole ecosystem and still not settled: nobody has a model that survives flyaway hair, fur, and semi-transparency every time. So the honest advice is to run your three hardest images through a couple of these and keep whichever loses the least detail, rather than trusting that RMBG-2.0 is always best. It usually is. Not always.

The inputs that actually matter are few. model is the big one. sensitivity scales how aggressively it decides what's foreground - dial it down if the cutout is eating into your subject, up if it's leaving background scraps. process_res controls the internal working resolution (256–2048); push it higher for detailed edges at the cost of VRAM and time. Then there's the edge-cleanup trio: mask_blur softens jagged edges, mask_offset grows or shrinks the mask by a few pixels (negative to bite in past a haloed edge, positive to keep a sliver of hair), and refine_foreground, which runs fast foreground color estimation to clean up the fringe - worth enabling when you're keeping the transparency. background picks Alpha (real transparency, RGBA out) or Color, and background_color sets that fill.

You get three outputs. IMAGE is the processed picture - transparent or filled depending on your background choice. MASK is the binary foreground mask, which is the one you route into inpainting, compositing, or an AILab_CropObject downstream. MASK_IMAGE is that mask rendered as a viewable black-and-white image, handy for eyeballing what the model actually grabbed before you commit.

Installing is the standard pack routine. Either search "Comfyui-RMBG" in ComfyUI Manager and install, or clone it: cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then ./ComfyUI/python_embeded/python -m pip install -r requirements.txt and restart. The model weights aren't bundled - they download themselves into ComfyUI/models/RMBG/ the first time you run each model, so your first RMBG-2.0 run stalls for a bit while it pulls the checkpoint, then it's cached and fast. One heads-up if you're shipping a commercial product: this pack is GPL-3.0, which is stricter than the MIT license on most of the models it wraps.

Where people get burned: feeding a 4K image expecting 4K-sharp edges. These models work at a fixed internal resolution and downscale your input first, so the very edge detail you wanted gets thrown away before inference - if you're above ~1500px and edges matter, that's a job for the BiRefNet node's HR weights, not this one. The other classic mistake is reaching for RMBG on genuinely semi-transparent stuff - a veil, a wine glass, smoke. A hard foreground/background label physically can't represent a half-transparent pixel, so it'll look clean on the grey preview and fall apart on a colored background. That's what the SDMatte node exists for. And if you're removing backgrounds to clean up a LoRA training set - don't. It teaches the LoRA to generate blank backgrounds. That one's cost a lot of people a lot of retrains.

Category🧪AILab/🧽RMBG

Inputs (10)

NameTypeDefaultDescription
imageIMAGEInput image to be processed for background removal.
modelCOMBOSelect the background removal model to use (RMBG-2.0, INSPYRENET, BEN).
sensitivityoptFLOAT1.000–1Adjust the strength of mask detection (higher values result in more aggressive detection).
process_resoptINT1024256–2048Set the processing resolution (higher values require more VRAM and may increase processing time).
mask_bluroptINT00–64Specify the amount of blur to apply to the mask edges (0 for no blur, higher values for more blur).
mask_offsetoptINT0-64–64Adjust the mask boundary (positive values expand the mask, negative values shrink it).
invert_outputoptBOOLEANfalseEnable to invert both the image and mask output (useful for certain effects).
refine_foregroundoptBOOLEANfalseUse Fast Foreground Colour Estimation to optimize transparent background
backgroundoptCOMBOAlphaChoose output type: Alpha (transparent) or Color (custom background color).
background_coloroptCOLORCODE#222222Pick background color (supports alpha, use color picker).

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE