Nodes//Whisker: BG Remove + Compose
ComfyUI Node

Whisker: BG Remove + Compose

Cut the background out and drop the subject on a canvas — one node, not five

By nerdywhiskers·Created 5 months ago·Updated a day ago· 1
Whisker: BG Remove + Compose
  • image
  • image
  • mask
modelBiRefNet
canvas_width1024
canvas_height1024
backgroundalpha
bg_color#ffffff
positionmiddle-center
fit_to_canvasfalse
original_image_scale1.00
padding_top0
padding_bottom0
padding_left0
padding_right0
crop_padding20

The classic background-removal graph in ComfyUI is five nodes long: load the model, predict the mask, extract the mask, crop to the bounding box, resize, then composite. Whisker's bg_remove_compose collapses that whole chain into one box. You feed it an image, tell it the canvas size, and it hands you a 4-channel RGBA cutout already positioned on that canvas - plus the mask it used, if you want to do anything else with it.

This sits on the most commoditized operation in the ecosystem, so let's be precise about what it's wrapping. Background removal is a solved-at-model level problem; BiRefNet is the default cutout model these days - MIT-licensed, the same one ComfyUI now ships in core - and it's what this node uses out of the box. What Whisker adds is the compose half. Most cutout nodes stop at the mask; this one finishes the job, which makes it the node you reach for when you're building product shots, profile cards, or any "subject on a clean background" template over and over.

How it works

Under the hood it loads the model from your HuggingFace cache via transformers (AutoModelForImageSegmentation, trust_remote_code), predicts a mask, crops the subject to its tight bounding box, resizes it, and alpha-blends it onto a canvas of your width × height. The mask is always resized to the final asset size, so you get clean edges even when the subject is scaled up or down. The model is moved to the GPU only during inference and back to CPU between calls, so it shares VRAM with your diffusion model instead of squatting on it.

The inputs that matter

Most of the schema is self-explanatory, but three choices decide your result:

  • model - BiRefNet (MIT, fine for commercial work) or RMBG-2.0 (BRIA, non-commercial without a paid license). If there's any chance the output is going into something you sell, stick with BiRefNet and don't think about it again.
  • background - alpha gives you a transparent canvas (true RGBA output); color gives you a solid bg_color canvas with the subject alpha-blended over it, and an opaque alpha channel so it saves like a normal PNG.
  • position + resize_to_fit/scale - the 9-grid positioner works on a third of the canvas, not the whole thing: top-left centers the asset in the top-left third, it doesn't jam it into the corner. With a large asset the placement barely shows. To actually see regional placement, either turn resize_to_fit on (which fits the asset inside the canvas minus padding_*, preserving aspect) or drop scale below 1.

Both outputs are always produced: image (RGBA) and mask.

Installing it

ComfyUI Manager is the easy path: search "ComfyUI-Whisker-Nodes" and install, then restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/nerdywhiskers/ComfyUI-Whisker-Nodes.git
pip install -r ComfyUI-Whisker-Nodes/requirements.txt

On the Windows portable build, use python_embeded\python.exe -m pip install ... instead of pip. The requirements are transformers>=4.40, numpy, Pillow, and timm>=1.0. You'll find it under Add Node → whisker-nodes.

Where people get burned

  • The first run downloads the model. ~880MB for BiRefNet into ~/.cache/huggingface/hub/. It's not hung, it's downloading - and switching to RMBG-2.0 pulls another ~885MB.
  • The timm error. If you hit an ImportError mentioning timm.layers, your timm is too old: pip install --upgrade "timm>=1.0" in the same Python that runs ComfyUI (portable users, that's the python_embeded interpreter, not your system pip).
  • A missing transformers install is the other classic; the node will tell you exactly that, so run pip install transformers.

Nothing here calls an API and nothing needs a key. First model load is the only "wait, is this broken?" moment.

Categorywhisker-nodes

Inputs (14)

NameTypeDefaultDescription
imageIMAGE
modelCOMBOBiRefNet2 options: BiRefNet, RMBG-2.0
canvas_widthINT102416–8192
canvas_heightINT102416–8192
backgroundCOMBOalpha2 options: alpha, color
bg_colorSTRING#ffffff
positionCOMBOmiddle-center9 options: top-left, top-center, top-right, middle-left, middle-center, middle-right, +3
fit_to_canvasBOOLEANfalseFit the cropped asset into the canvas proportionally. When enabled, original image scale is ignored.
original_image_scaleFLOAT1.000.1–2Scale factor applied to the cropped asset. Ignored while fit to canvas is enabled.
padding_topINT00–4096
padding_bottomINT00–4096
padding_leftINT00–4096
padding_rightINT00–4096
crop_paddingINT200–4096

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK