Nodes/ComfyUI_BiRefNet_Universal/BiRefNet Remove Background🌟
ComfyUI Node

BiRefNet Remove Background🌟

Hair-safe cutouts without leaving ComfyUI

By moon7star9·Created about a year ago·Updated 10 months ago· 25
BiRefNet Remove Background🌟
  • model
  • image
  • image
  • mask
background_colortransparency
use_refinetrue

If you've ever run an old-school background remover on a photo with hair and gotten back what looks like a helmet, you already know the problem this node exists to fix. BiRefNet Remove Background cuts a subject out of an image using BiRefNet, the model that quietly took over as the community's default background remover once people got tired of rembg's u2net mangling flyaway strands, fur and anything semi-transparent. This node is the actual "do the cutout" step - you feed it a loaded BiRefNet model and an image, and it hands back a clean subject plus a mask.

Why BiRefNet and not the old stuff

BiRefNet wasn't even built for background removal - the paper targets dichotomous image segmentation, and the same weights also top salient-object and camouflage benchmarks - but it turned out to be dramatically better at exactly the case u2net always botched: hair, fur, fabric mesh, glass. The trick is a two-module design: one part localizes the subject using global context, the other reconstructs the mask against two references at once - image patches and gradient maps - which is what lets it hold onto fine detail instead of drawing a blob around "the person." It's MIT-licensed, free for commercial use, and maintained by one PhD researcher (Peng Zheng) who's kept shipping practical weight variants - general, HR, lightweight, portrait, dedicated matting - instead of stopping at the paper's benchmark numbers. One honest caveat: it's not an undisputed win. InSPyReNet still beats it in some people's side-by-sides, so if edges really matter for your use case, test both on your hardest image rather than assuming BiRefNet wins by default.

The inputs and outputs that matter

This particular node keeps it simple - four inputs, two outputs:

  • model (BIREFNET_MODEL) - not the checkpoint itself, but the output of a BiRefNet model-loader node elsewhere in this pack. That's where you actually pick which BiRefNet variant runs: general-purpose for most photos, an HR variant if your input is a big image, a matting variant if you're dealing with veils, glass or wispy hair where a hard mask isn't enough.
  • image (IMAGE) - the photo you want cut out.
  • background_color - what fills in behind the subject once it's removed. Six choices: transparency (default), white, black, green, blue, red. If you pick transparency, remember to save as PNG downstream - anything that flattens to JPEG will throw the alpha channel away and you'll be left wondering why your "transparent" background came back solid.
  • use_refine - a boolean, on by default. Leave it on unless you're batting through a huge batch and need the extra speed; the refine pass is there to clean up the mask, and turning it off trades some edge quality for throughput.

Out the other end you get image (the composited result, ready to save or feed into the next node) and mask (the raw alpha/segmentation mask - useful on its own if you want to composite the subject somewhere else, feed it to an inpaint node, or reuse it as a selection).

Installing it

Easiest path: open ComfyUI Manager, search for ComfyUI_BiRefNet_Universal, install, restart. Doing it by hand is just as simple:

cd ComfyUI/custom_nodes
git clone https://github.com/moon7star9/ComfyUI_BiRefNet_Universal

then restart ComfyUI. The pack manages models for you - point the loader node at whichever BiRefNet variant you want and it'll pull from a local models/BiRefNet/ folder or auto-download from HuggingFace on first use. On a slow connection, downloading the weights into models/BiRefNet/ ahead of time beats a stalled first run mid-workflow.

Common issues

Picking the wrong model variant is the #1 way people get worse results than they should. Feeding a large image into a model trained at 1024×1024 downscales it internally and throws away exactly the edge detail you were trying to keep - if your source image is above roughly 1500px, use an HR variant in the loader instead of the default. And a segmentation-style variant simply can't represent a half-transparent pixel; if you're cutting out glass, smoke, or a veil, you need one of the matting weights, not the general one - no amount of use_refine fixes that structurally.

Stale bundled weights. This is a real, documented failure mode in the BiRefNet node ecosystem specifically - the model's own author has publicly pointed people away from a popular ComfyUI node because its bundled weights hadn't been updated in months and results looked worse than they should. If your cutouts look off compared to what you've seen elsewhere, check that this pack (and its downloaded weights) are current before blaming the model.

One last honest note: if you don't need the model-variant flexibility, ComfyUI has shipped BiRefNet natively since May 2026. This pack earns its keep when you want control over exactly which BiRefNet weights run - otherwise it's one of several roads to the same model.

CategoryBiRefNet🌟

Inputs (4)

NameTypeDefaultDescription
modelBIREFNET_MODEL
imageIMAGE
background_colorCOMBOtransparency6 options: transparency, white, black, green, blue, red
use_refineBOOLEANtrue

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK