Background Remover — RMBG / BiRefNet
Background removal with the two models that actually matter — and a licensing warning you should read first
- image
- foreground
- mask
- info
Background removal is the most commoditized operation in this ecosystem, and also the least settled - nobody has won the hair-and-fur war. This node gives you two serious contenders and lets you pick which failure you can tolerate: RMBG-2.0 for speed, BiRefNet for edges. It's the one-click version of the workflow you'd otherwise assemble from a separate RMBG pack and a BiRefNet pack, wrapped into a single IMAGE-in, IMAGE + MASK-out node.
You'll reach for it for product shots, portrait cutouts before compositing, or as a pre-stage before inpainting - drop the background, then inpaint the clean area behind your subject.
How it works
The node sits on top of the pack's shared model manager, which auto-downloads weights from HuggingFace on first use. Three backends:
- rmbg_2.0 - general-purpose and fast (briaai/RMBG-2.0).
- birefnet_general - high-detail edges, the community default for anything with hair or fur.
- birefnet_portrait - same network, tuned for human portraits.
BiRefNet is the model that displaced rembg's u2net precisely because its bilateral-reference design survives fine hair and semi-transparent material (the KB's background-removal doc is a good deep dive on why). After inference, the node applies a threshold to turn the soft alpha into a hard mask, optionally blurs the edges, and premultiplies the foreground so it composites without a gray fringe.
The inputs that matter
- image - any batch of images.
- model_name - defaults to
birefnet_general; that's a sensible default. Swap tormbg_2.0when you need throughput. - threshold (0.5) - how hard the mask is.
0= fully soft,1= fully hard. - invert - keep the background instead of the subject.
- mask_blur (0) - Gaussian blur on the final mask edges; handy for soft compositing.
- keep_model_loaded - keep the weights in VRAM between runs (default on). Toggle off on low-VRAM cards.
Outputs are foreground (premultiplied RGB), mask (the alpha), and info (JSON of what ran).
Installing it
Part of ComfyUI-CustomNodePacks. ComfyUI Manager → search "CustomNodePacks", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
Restart, then be patient on the first run: the model downloads from HuggingFace when you first execute the node (a few hundred MB). Offline setups need to drop the weights into the pack's model cache manually.
The licensing warning
Read this before you ship a client deliverable. RMBG-2.0 is non-commercial. The BRIA AI RMBG License restricts commercial use, and the pack's own notice is blunt about it: use rmbg_2.0 for paid work and you must buy a commercial license from Bria, or switch to a BiRefNet backend, which is MIT and commercially fine. The source registry confirms the split: RMBG pulls briaai/RMBG-2.0, BiRefNet pulls ZhengPeng7/BiRefNet. If you're doing anything commercial, just default to birefnet_general and you're legally in the clear.
Gotchas
First-run download stalls are the usual complaint - the model manager has to fetch weights, so if you're offline or behind a proxy, that's your failure mode, not the node itself. On low-VRAM cards, leaving keep_model_loaded on across a big pipeline can crowd out your diffusion model; toggle it off between runs. And for really gnarly edges - flyaway hair on a bright sky - no single pass will be perfect; that's what the pack's Matting and ViTMatte nodes are for downstream.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image(s) to remove background from. | |
| model_name | COMBO | birefnet_general | Background removal model: rmbg_2.0: General-purpose, fast. birefnet_general: High-detail edges. birefnet_portrait: Optimized for human portraits. |
| threshold | FLOAT | 0.500–1 | Alpha threshold for hard mask (0=soft, 0.5=balanced, 1=hard). |
| invert | BOOLEAN | false | Invert the alpha mask (keep background instead). |
| mask_blur | INT | 00–50 | Gaussian blur applied to final mask edges. |
| keep_model_loadedopt | BOOLEAN | true | Keep model in VRAM between runs. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| foreground | IMAGE | Foreground RGB image with background removed (premultiplied by alpha). |
| mask | MASK | High-quality alpha mask for the foreground subject. |
| info | STRING | JSON summary of the parameters used for this run. |