🧹BiRefNet
Cut Out Hair, Fur, Even a Whole Video — Background Removal That Keeps the Edges
- birefnetmodel
- image
- image
- mask
The 🧹BiRefNet node is the part of ZHO's pack that actually does the cutting. Feed it a loaded model and any image - or a whole batch of frames - and it hands you back a transparent-background image and a mask. That two-output split is the upgrade this pack made over the older viperyl/ComfyUI-BiRefNet, which only spat out a mask and was useless for video. ZHO's version does the transparent PNG directly and loops over batches, which is how the same node cuts a video frame by frame.
Why reach for BiRefNet at all instead of the rembg nodes you already have? Edges. The model's bilateral-reference architecture - a localization module that finds the subject, then a reconstruction module that refines against gradient maps - is exactly why flyaway hair, fur and fabric mesh survive the cut where u2net's mask turns into a fuzzy mess. It's the default recommendation for anything with a difficult boundary, and it's MIT-licensed, so commercial product work is fine.
How it works
Per image (or per frame), the node converts to PIL, resizes to 1024×1024, normalizes, runs the network, and sigmoids the output into a soft mask. Then it interpolates back up to your original resolution, min-max stretches the values for contrast, and pastes the original onto a transparent canvas using that mask as alpha. The image output is the result - an RGBA image, transparent where the background used to be. The mask output is the same cutout as a plain mask, which is what you feed into compositing, inpainting or a mask editor.
Two things worth knowing from the source: the 1024 resize is hardcoded, and the mask is min-max stretched. That second one means the mask is a contrast-boosted cutout, not calibrated confidence - perfectly good for compositing, just don't read it as probability.
Inputs and outputs
Everything that matters, and it's all of it:
- birefnetmodel (
BRNMODEL) - comes from the 🧹BiRefNet Model Loader. Nothing else will do. - image (
IMAGE) - any image tensor. Feed it a batch of frames from a video-load node and it cuts every frame; that's your "video background removal" feature. - image (
IMAGE) - RGBA output, transparent background. Save it straight to PNG. - mask (
MASK) - the cutout as a mask, for compositing or downstream editing.
Install
This pack ships both nodes, so install is shared. ComfyUI Manager, searching for BiRefNet-ZHO, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ZHO-ZHO-ZHO/ComfyUI-BiRefNet-ZHO.git
cd ComfyUI-BiRefNet-ZHO
pip install -r requirements.txt # just timm
Restart, then drop the checkpoints from the README's linked HuggingFace repo (ViperYX/BiRefNet) into ComfyUI/models/BiRefNet. birefnet-general.pth alone gets you going. If you get an import error, timm isn't installed - that's the one real dependency, used by the Swin backbone inside the pack.
Where people get burned
The hardcoded 1024 resize is the big one. Feed this a 4K product photo and the model downsizes it internally, then upscales the mask back - you lose exactly the fine edges you bought BiRefNet for. For inputs above roughly 1500px, the HR or dynamic checkpoints running through ComfyUI-RMBG (or native ComfyUI since May 2026) do better. For typical photos and web images, this node is fine.
And don't reach for it everywhere. Solid subject on a plain background? rembg with u2net is faster, smaller, and solved that case years ago. LoRA training? The community's most repeated finding is that stripping backgrounds from training images teaches the model to output blank backgrounds - keep the originals and caption honestly instead. And the BiRefNet-versus-InSPyReNet argument is genuinely unresolved, so when the cut really matters, run both and keep the one your own three hardest images prefer. This pack is precisely the pair the most-upvoted dedicated background-removal workflow chains together to do that comparison on your own data.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| birefnetmodel | BRNMODEL | — | |
| image | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |