BiRefNet RemoveBG (SBTools)
The background remover that finally gets hair right — five BiRefNet variants in one node
- image
- background_color
- IMAGE
- MASK
- MASK_IMAGE
Removing a background is the operation everyone assumes is solved until they hit flyaway hair, fur, or fabric mesh. That's the case BiRefNet was adopted for, and it's what this node wraps: five BiRefNet model variants behind one interface, with mask refinement built in. It's the flagship of the ComfyUI-SBTools pack, and honestly the reason most people install the pack at all.
If you're newer to the ecosystem, the short version of the BiRefNet story is this: the old default (rembg's u2net) is fast and fine on clean subjects and visibly wrong on hard edges. BiRefNet, a segmentation network that was never built for background removal, became the community default because the difference shows up in a side-by-side rather than in a metric - hair survives. It's MIT-licensed, runs in well under a second at typical resolutions, and ComfyUI even shipped it natively in core in May 2026.
So why use this node instead of the built-in? Two reasons. First, it bundles five variants including BiRefNet_toonout, which extracts outlines instead of a mask - a creative effect core ComfyUI doesn't give you. Second, it's the natural partner to this pack's Alpha to Chroma Key node: cut out, fill, key.
Which model do you actually want?
- BiRefNet-general - 1024×1024, fast and balanced. The default for most jobs.
- BiRefNet-HR - 2048×2048, best detail preservation, roughly 4× slower. Reach for it above ~1500px inputs.
- BiRefNet-portrait - trained on human subjects, better hair and skin separation for people.
- BiRefNet_dynamic - preserves aspect ratio (256–2304px), so wide and tall images don't get squashed. Use this for non-square inputs.
- BiRefNet_toonout - line-art / outline extraction instead of a cutout. For stylized effects.
That resolution detail is where most people self-inflict bad results. The square models (general, HR, portrait, toonout) resize your image to a fixed square internally, so feeding a 4K image to the 1024 model downscales it and throws away exactly the edges you were trying to keep.
How it works
Models auto-download on first use to ComfyUI/models/sbtools/BiRefNet/ (from 1038lab/BiRefNet on HuggingFace) and cache afterwards. The node runs the segmentation, then applies your post-processing: mask_blur (0–64) softens edges, mask_offset (−20 to +20) expands or shrinks the boundary, and invert_output swaps foreground/background. The background toggle gives you Alpha (transparent) or Color with a hex background_color.
Outputs are the three you'd expect: IMAGE (cutout, transparent or colored background), MASK (grayscale mask data for wiring into inpaint or detail pipelines), and MASK_IMAGE (an RGB visualization of the mask so you can eyeball it).
Refinement that actually fixes things
Start at mask_blur: 0 and mask_offset: 0. If edges look crunchy, mask_blur: 2–5 smooths them. If the mask cuts too tight (you're losing hair), mask_offset: +2 to +5 pulls it outward. If it's grabbing background, go negative. The blur is applied with a Gaussian and the offset with Max/Min filters, so the results are predictable - no voodoo.
Installing it
Same as every node in the pack - ComfyUI Manager → search "ComfyUI-SBTools" → Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Amatsukast/ComfyUI-SBTools.git
cd ComfyUI-SBTools
pip install -r requirements.txt
Only huggingface_hub and kornia are required, so no heavy dependency surprises. Restart after install.
Troubleshooting
- First run hangs / downloads - that's normal, the model is downloading. Watch the console for progress.
- Wide image looks squashed - you used a square model. Switch to
BiRefNet_dynamic. - VRAM warnings on HR - BiRefNet-HR wants more memory;
generalis the budget option and the difference is often small on everyday resolutions. - Edges are wrong - almost always a resolution problem (see above) before it's a model problem. Run the same image through general and HR and compare; that's a better use of time than tweaking offsets.
One licensing note: the node code is GPL-3.0 because it's based on ComfyUI-RMBG, but the BiRefNet weights themselves are MIT, so commercial use of the output is fine.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to be processed for background removal. | |
| model | COMBO | BiRefNet-HR | Select the BiRefNet model variant to use. |
| 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-20–20 | 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). |
| backgroundopt | COMBO | Alpha | Choose background type: Alpha (transparent) or Color (custom background color). |
| background_coloropt | COLORCODE | #222222 | Choose background color (Alpha = transparent) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| MASK_IMAGE | IMAGE | — |