Nodes/ComfyUI-RMBG/BiRefNet (RMBG)
ComfyUI Node Runs on cloud

BiRefNet (RMBG)

BiRefNet (RMBG)

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
BiRefNet (RMBG)
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
model
mask_blur0
mask_offset0
invert_outputfalse
refine_foregroundfalse
backgroundAlpha

BiRefNet is the model that quietly became the default background remover for this whole scene, and this node is the ComfyUI-RMBG way to run it with its full family of weights exposed in one dropdown. If the plain RMBG node's four models aren't cutting hair or fur cleanly enough, this is where you go. It's the same idea - feed an image, get a cutout and a mask - but with the model everyone reaches for when the edges are the hard part.

Worth knowing what BiRefNet actually is, because it explains why it's good. It's an academic segmentation network (Bilateral Reference) that was never built for background removal specifically - the paper targets dichotomous image segmentation and the same weights top salient-object and camouflaged-object benchmarks too. The trick is a reconstruction module that rebuilds the mask against two references at once, one of them gradient maps, with supervision pushed onto fine detail. That's the reason hair strands survive where older models like u2net just smeared them. It's MIT-licensed and Freepik funded the practical high-res weights, which is why the family kept growing.

And the family is the whole point of this node. The model dropdown carries eleven weights and picking the right one matters more than any other setting. BiRefNet-general is the default 1024px workhorse. BiRefNet-HR is trained at 2048 - use it for anything above roughly 1500px, or the general model downscales your input internally and throws away the edges you were trying to keep. BiRefNet_dynamic was trained across a range of sizes, so it's the safe pick when your batch is mixed or unpredictable resolutions. The -matting, -HR-matting, and _lite-matting variants are a different output type, not a better version - they predict fractional alpha for genuinely semi-transparent material instead of a hard foreground label. _lite and _lite-2K are the lightweight Swin-Tiny tier for weaker GPUs. _toonout is tuned for illustration/anime. -portrait specializes in people.

Beyond the model, the controls are minimal on purpose: mask_blur to soften edges, mask_offset to grow or shrink the mask (here it's a tight -20 to 20 range), refine_foreground to clean the transparent fringe, invert_output to flip it, and background / background_color to output Alpha transparency or a solid fill. There's no sensitivity or resolution slider - the model handles that, which is part of why it's less fiddly than the main RMBG node. Outputs are the usual three: IMAGE (the cutout), MASK (the binary mask for downstream compositing or inpainting), and MASK_IMAGE (the mask as a viewable picture).

Install is the pack standard: search "Comfyui-RMBG" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG followed by pip install -r requirements.txt and a restart. Each BiRefNet weight downloads on first use into ComfyUI/models/RMBG/BiRefNet/, so switching models the first time means a download wait. FP16 inference is basically free here - under a second per image on consumer hardware at 1024, a few gigs of VRAM - so don't overthink the performance.

One thing to keep honest: BiRefNet is the right default, but it hasn't won outright. InSPyReNet (which lives on the RMBG node as INSPYRENET, or as a standalone node) still beats it on some material, and as recently as early 2026 the highest-scoring background-removal thread going around was recommending InSPyReNet over it. There's no leaderboard that settles this. If a BiRefNet cutout disappoints you on a specific image, swap the model and try again before assuming you did something wrong. Also, if you're already on a recent ComfyUI, BiRefNet-general ships in core now under a native background-removal folder - so you don't strictly need this node for the default weights. What this node still gives you is the full variant family and the matting weights behind one interface, which core doesn't.

Category🧪AILab/🧽RMBG

Inputs (8)

NameTypeDefaultDescription
imageIMAGEInput image to be processed for background removal.
modelCOMBOSelect the BiRefNet model variant to use.
mask_bluroptINT00–64Specify the amount of blur to apply to the mask edges (0 for no blur, higher values for more blur).
mask_offsetoptINT0-20–20Adjust the mask boundary (positive values expand the mask, negative values shrink it).
invert_outputoptBOOLEANfalseEnable to invert both the image and mask output (useful for certain effects).
refine_foregroundoptBOOLEANfalseUse Fast Foreground Colour Estimation to optimize transparent background
backgroundoptCOMBOAlphaChoose background type: Alpha (transparent) or Color (custom background color).
background_coloroptCOLORCODE#222222Choose background color (Alpha = transparent)

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE