🔥BiRefNet
The BiRefNet cutout node the model's own author points people to
- image
- image
- mask
If you've been cutting out backgrounds in ComfyUI for more than a week, you already know the name: BiRefNet is the model that made rembg's u2net look like a 2020 throwaway on hair, fur and fabric mesh. This is the ComfyUI node for it, and it carries one credential no other BiRefNet wrapper has: the model's own author recommends it. Peng Zheng has popped into Reddit threads more than once to tell people to use MoonHugo's pack over the alternatives because it tracks the current weights while the others shipped stale ones. When the person who trained the model is doing tech support for a node he didn't write, that's the signal to read.
What it actually does
It's a one-node pack - just 🔥BiRefNet, class BiRefNet_Hugo. Feed it an image, it segments the salient subject, and returns two things: the cutout (on transparency or any of 26 solid background colors) and the mask. Nothing else. That's the whole pack, and that's fine, because background removal is a solved-enough problem that you don't want a node farm for it.
Under the hood it's the standard BiRefNet path: AutoModelForImageSegmentation.from_pretrained(...) with trust_remote_code, a forward pass, sigmoid, min-max normalization, then resize back to your original dimensions. The mask it hands you is soft grayscale, not a hard binary - semi-transparent edges survive instead of turning into jagged steps.
The trap nobody warns you about
The node's preprocessing hardcodes a 1024×1024 resize for every model. That means picking ZhengPeng7/BiRefNet_HR doesn't unlock its 2048 native resolution - this node downscales your input to 1024 before inference and upscales the mask afterwards. Feed it a 4K render and you'll lose exactly the edges you installed BiRefNet for. For typical 1024-class generations it's a non-issue; for big images, this is the wrong node, and honestly the wrong approach - that's the classic "self-inflicted quality loss" the community keeps warning about. Just know what you're getting.
The inputs that matter
Most of the fields are fine at their defaults. The three you'll actually touch:
model-ZhengPeng7/BiRefNet(the default all-rounder),BiRefNet_HR(marginally better edges, wasted through this node's resize), orBiRefNet-portrait(the people specialist, trained on P3M-10k). If your subject is a person, portrait is the interesting one.load_local_model+local_model_path- for offline use. Flip the boolean and point the path at a folder with the HF-style files (config.json+ weights). The default path is somewhere useless; set it yourself.background_color_name- defaults totransparency(real RGBA alpha). Change it to a named color if you want a flat background instead.
device can stay on auto - it picks CUDA, MPS, XPU or CPU sensibly.
The two outputs wire up exactly how you'd expect: image goes to a Save/Preview or composite, and mask feeds the compositing side - stack it into InpaintAnything, or hook it to a SetLatentNoiseMask before a KSampler if you want to regenerate just the subject against a new scene.
Install
Standard three ways. ComfyUI Manager: search "ComfyUI-BiRefNet-Hugo". Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/MoonHugo/ComfyUI-BiRefNet-Hugo.git
cd ComfyUI-BiRefNet-Hugo
pip install -r requirements.txt
Restart ComfyUI. First run downloads the model from HuggingFace (hundreds of MB), so have a network connection - or pre-download and use the local path above.
Troubleshooting
Two things will bite you. First, requirements.txt only lists numpy and timm, but the node actually imports transformers and torchvision. If ComfyUI's Python env doesn't already have transformers, you'll get an import error that pip install -r requirements.txt won't fix. Just pip install transformers. Second, the node loads in FP32 and never bothers with half precision, so expect the fatter side of BiRefNet's VRAM curve - roughly 4.8GB at 1024×1024 rather than the 3.5GB the author's FP16 numbers advertise.
One last honest note: since May 2026 ComfyUI ships a single birefnet.safetensors in core. If the default model is all you need, you may not need this pack at all. You install it for the model selector - and for the endorsement.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | ZhengPeng7/BiRefNet | 3 options: ZhengPeng7/BiRefNet, ZhengPeng7/BiRefNet_HR, ZhengPeng7/BiRefNet-portrait |
| load_local_model | BOOLEAN | false | — |
| background_color_name | COMBO | transparency | 26 options: transparency, green, white, red, yellow, blue, +20 |
| device | COMBO | auto | 6 options: auto, cuda, cpu, mps, xpu, meta |
| local_model_pathopt | STRING | /tmp/ComfyUI/custom_nodes/ComfyUI/models/BiRefNet | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |