π Remove Background
Cutouts that survive hair, without assembling a pipeline
- image
- image
- mask
Background removal is one of those operations where the old tools are fine until they aren't - and the moment you cut out a person with flyaway hair, you find out your u2net-based setup was never going to make it. This node runs BiRefNet, which is the model that displaced rembg's u2net as the default for hard edges: hair, fur, fabric mesh, semi-transparent material. You feed it an image, it returns a clean cutout and a mask, and that's the whole node. No separate model loader, no preprocessing chain, no manual thresholding.
One important context if you've been following along: BiRefNet is now bundled inside ComfyUI core (since May 2026), so you have a native path too. This node is the pack's all-in-one take - and honestly the main thing it adds over the core setup is a model picker and a background-color choice in one place.
How it works
The node vendors the ZhengPeng7 BiRefNet weights and downloads them on first use into ComfyUI/models/ComfyUI-YarvixPA/RemoveBackground/<model>/ via HuggingFace - which means the first run needs internet and takes a while. It then pads and resizes your image to the model's native resolution, runs inference in fp16 on your GPU, and post-processes the mask back to the original size.
Four models, and picking wrong is the most common mistake:
- BiRefNet (default) - the 1024Γ1024 general model. The right call for most images.
- BiRefNet_lite - Swin-Tiny backbone for tight VRAM. A step down in edge quality.
- BiRefNet_lite-2K - 2560Γ1440, for large sources on constrained hardware.
- BiRefNet_dynamic - handles arbitrary input resolutions natively. Use this for anything big - feeding a 4K image into the fixed 1024 model internally downscales it and throws away exactly the hair detail you wanted kept.
background_color picks what fills where the background was: transparency (RGBA output), white, or black. device defaults to auto. update_model (default off) forces a re-download if you think the weights are stale.
Outputs are image (the cutout) and mask (single-channel), which you can wire into a compositing or masking workflow directly.
Install
ComfyUI Manager (search "YarvixPA") or
cd ComfyUI/custom_nodes
git clone https://github.com/YarvixPA/ComfyUI-YarvixPA
restart. This is the one node in the pack with heavy real dependencies: the pack's requirements.txt pulls opencv-python and timm (BiRefNet's Swin backbone needs timm), plus torchvision which ComfyUI core already provides. Manager installs them.
Where people get burned
The big one: the model is loaded from disk on every execution. There's no caching - each run reconstructs the BiRefNet network, so don't drop this node inside a per-frame loop and expect real-time. It's a "run it once, save the result" node, not a per-batch engine.
Second: the transparency output is a flat RGBA image. If you save it with ComfyUI's SaveImage you get a PNG with alpha - good - but any downstream node that strips alpha (most do) silently flattens it. Grab the mask output too if you need to re-composite later.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| model | COMBO | BiRefNet | 4 options: BiRefNet, BiRefNet_lite, BiRefNet_lite-2K, BiRefNet_dynamic |
| background_color | COMBO | transparency | 3 options: transparency, white, black |
| device | COMBO | auto | 3 options: auto, cuda, cpu |
| update_model | BOOLEAN | false | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| mask | MASK | β |