𝙆 Remove BG
The BiRefNet-powered half of KayTool's background removal
- remove_bg
- image
- IMAGE
- MASK
Cutting a subject out of an image is the single most commoditized operation in this whole ecosystem - every pack seems to have its own version - and KayTool actually ships two separate background-removal paths. This node is the BiRefNet one. It doesn't do the segmentation itself; it takes a loaded BiRefNet model (from KayTool's BiRefNet Loader node, which outputs a REMOVE_BG type made specifically for this node) and an image, and hands back a cutout plus its mask.
BiRefNet is, as of now, the field's default recommendation for anything with a genuinely hard edge - hair, fur, semi-transparent fabric - the cases where older tools like rembg's u2net visibly fall apart. It wasn't even built for background removal originally (the paper targets a broader segmentation task), but the edge quality is what made it take over. It's not an uncontested win, though: InSPyReNet, a rival network, still beats it in specific comparisons people run themselves, and there's no shared benchmark that settles it either way. If your cutouts on hair or fur aren't landing, it's worth knowing BiRefNet isn't automatically the ceiling - just the best default bet.
How it works
You load a model once with BiRefNet Loader (pick BiRefNet, BiRefNet_HR, or BiRefNet-portrait, and a hardware provider), then feed that REMOVE_BG output into this node alongside your image. Remove BG runs the segmentation and gives you back the cut-out image and its mask. The Preview dropdown lets you slam the result against a solid black, white, gray, red, green, or blue backdrop right in the node - a fast way to eyeball edge quality before you trust it, since a cutout that looks clean against the default preview can still show flyaway hairline artifacts against a real background. Blur and Expand do the same soft-edge job as KayTool's Mask Blur + node, baked directly into this one so you don't need a second node just to feather the result.
The inputs and output that matter
- remove_bg (REMOVE_BG) - the loaded model, from
BiRefNet Loader. - image (IMAGE) - the source photo.
- Preview (choice of none / Black / White / Gray / Red / Green / Blue) - quick visual validation of the cutout.
- Blur (0–256) / Expand (-5 to 5) - soften and grow/shrink the resulting mask, same mechanism as
Mask Blur +. - invert_mask (BOOLEAN) - flips the mask if the foreground/background come out backwards.
- IMAGE / MASK (outputs) - the cutout and its mask, ready for compositing or inpainting.
Note this is separate from the pack's other background-removal pair, RemBGLoader / RemoveBG, which wraps the older rembg models (u2net, isnet, SAM) via a different REMBG_LOADER type - those aren't covered in this article, but if your node search turns up two similarly-named removal nodes, that's why.
Installing it
Whole-pack install: ComfyUI Manager → search KayTool → install → restart, or git clone https://github.com/kk8bit/KayTool into ComfyUI/custom_nodes and restart. BiRefNet's weights aren't part of the git clone - they download from HuggingFace the first time you actually run the BiRefNet Loader node, so budget a few hundred MB to a couple GB of bandwidth and disk on first use depending on which weight you pick.
Common issues
If the first run hangs or errors, it's almost always the model download stalling - check your network and disk space before assuming the node is broken. If cutouts on fine hair or fur look rougher than you expected, try the BiRefNet_HR weight in the loader instead of the base model (the standard weights are trained at a lower native resolution and will downscale a large input internally, throwing away exactly the detail you're trying to keep). And remember BiRefNet gives you a hard segmentation mask, not true partial alpha - for genuinely semi-transparent subjects like veils, glass, or smoke, no amount of blur/expand tuning here will recover detail a segmentation model was never built to represent.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| remove_bg | REMOVE_BG | — | |
| image | IMAGE | — | |
| invert_mask | BOOLEAN | false | Invert mask values (0->1, 1->0) |
| Preview | COMBO | 7 options: none, Black, White, Gray, Red, Green, +1 | |
| Blur | INT | 00–256 | — |
| Expand | FLOAT | 0.0-5–5 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |