Remove Background (RMBG)
RMBG (Remove Background)
- image
- background_color
- IMAGE
- MASK
- MASK_IMAGE
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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to be processed for background removal. | |
| model | COMBO | Select the background removal model to use (RMBG-2.0, INSPYRENET, BEN). | |
| sensitivityopt | FLOAT | 1.000–1 | Adjust the strength of mask detection (higher values result in more aggressive detection). |
| process_resopt | INT | 1024256–2048 | Set the processing resolution (higher values require more VRAM and may increase processing time). |
| mask_bluropt | INT | 00–64 | Specify the amount of blur to apply to the mask edges (0 for no blur, higher values for more blur). |
| mask_offsetopt | INT | 0-64–64 | Adjust the mask boundary (positive values expand the mask, negative values shrink it). |
| invert_outputopt | BOOLEAN | false | Enable to invert both the image and mask output (useful for certain effects). |
| refine_foregroundopt | BOOLEAN | false | Use Fast Foreground Colour Estimation to optimize transparent background |
| backgroundopt | COMBO | Alpha | Choose output type: Alpha (transparent) or Color (custom background color). |
| background_coloropt | COLORCODE | #222222 | Pick background color (supports alpha, use color picker). |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| MASK_IMAGE | IMAGE | — |