Nodes/ComfyUI 1hewNodes/Detect Remove BG
ComfyUI Node

Detect Remove BG

Five background-removal backends behind one node, RMBG by default

By 1hew·Created about a year ago·Updated 8 days ago· 33
Detect Remove BG
  • image
  • image
  • mask
modelRMBG-1.4
add_backgroundalpha

Background removal is the most commoditized operation in this ecosystem, and this node is the 1hewNodes take on it: one interface, five backends. Detect Remove BG (1hew_DetectRemoveBG) takes an image, cuts out the subject, and hands you both the cutout and the mask. The model dropdown is where the personality lives - it ranges from a dependency-free classic color-difference mode all the way to BiRefNet.

The default is RMBG-1.4, Bria's popular background-removal model, and here's the part that makes it beginner-friendly: the node auto-downloads the model into ComfyUI/models/rembg/ on first use. No hunting for a safetensors file, no manual placement - run it once, it fetches the weights, done.

The backends

  • none - no model at all. Estimates the border color and builds an alpha from color difference. Fast, free, and roughly as good as classic chroma-keying on flat backgrounds. A useful fallback when you can't download models.
  • RMBG-1.4 (default) - Bria's well-known model, run natively in PyTorch, auto-downloaded from Hugging Face. Solid general-purpose cutouts; the community's default for years.
  • RMBG-2.0 - the newer ONNX version. Auto-downloads too, but it needs onnxruntime installed (the node will tell you exactly this if it's missing).
  • birefnet-general / birefnet-general-lite - BiRefNet via rembg. This is the KB's recommended quality tier, notably better on hair and fine edges.
  • Inspyrenet - via transparent-background. The "absolute magic" pick in some corners of the community, and a good second opinion when BiRefNet fails you.

add_background decides what you get back: alpha (true RGBA cutout), or flattened onto white/black.

How it works under the hood

Models are loaded once and cached, then inference runs per-image with real concurrency - except RMBG-1.4 on CUDA, which deliberately runs serial because sharing that one model across threads is unstable (the code logs this when it happens). If RMBG-1.4 hits a CUDA out-of-memory, it retries on CPU automatically rather than dying. First run downloads whatever you picked, so budget a few hundred MB and a minute of patience.

Inputs and outputs

  • image - the input.
  • model - backend combo, default RMBG-1.4.
  • add_background - alpha / white / black.
  • image - the cutout (RGBA for alpha mode).
  • mask - the alpha mask, for inpainting or compositing.

Installing it

It's part of the 1hewNodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Then restart and let ComfyUI Manager install requirements - this node drags in rembg, transparent-background, and onnxruntime (for RMBG-2.0), which is the heaviest dependency load in the pack. Models auto-download to models/rembg/.

The honest take

The default RMBG-1.4 will get you 80% of the way on most images, and that's fine - the beauty of this node is that switching quality tiers is a dropdown change, not a new install. Where people get burned: the first-run download (it looks like a hang, it isn't), and RMBG-2.0 failing with a missing onnxruntime. If you care about hair and fine edges, go straight to birefnet-general and skip the default. And remember the mask output - for a "remove background then inpaint the subject" pipeline, that mask is worth as much as the cutout.

Category1hewNodes/detect

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
modelCOMBORMBG-1.46 options: none, RMBG-1.4, RMBG-2.0, birefnet-general, birefnet-general-lite, Inspyrenet
add_backgroundCOMBOalpha3 options: alpha, white, black

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK