Whisker: BG Remove + Compose
Cut the background out and drop the subject on a canvas — one node, not five
- image
- image
- mask
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) orRMBG-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-alphagives you a transparent canvas (true RGBA output);colorgives you a solidbg_colorcanvas 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-leftcenters 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 turnresize_to_fiton (which fits the asset inside the canvas minuspadding_*, preserving aspect) or dropscalebelow 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
timmerror. If you hit an ImportError mentioningtimm.layers, your timm is too old:pip install --upgrade "timm>=1.0"in the same Python that runs ComfyUI (portable users, that's thepython_embededinterpreter, not your system pip). - A missing
transformersinstall is the other classic; the node will tell you exactly that, so runpip install transformers.
Nothing here calls an API and nothing needs a key. First model load is the only "wait, is this broken?" moment.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | BiRefNet | 2 options: BiRefNet, RMBG-2.0 |
| canvas_width | INT | 102416–8192 | — |
| canvas_height | INT | 102416–8192 | — |
| background | COMBO | alpha | 2 options: alpha, color |
| bg_color | STRING | #ffffff | — |
| position | COMBO | middle-center | 9 options: top-left, top-center, top-right, middle-left, middle-center, middle-right, +3 |
| fit_to_canvas | BOOLEAN | false | Fit the cropped asset into the canvas proportionally. When enabled, original image scale is ignored. |
| original_image_scale | FLOAT | 1.000.1–2 | Scale factor applied to the cropped asset. Ignored while fit to canvas is enabled. |
| padding_top | INT | 00–4096 | — |
| padding_bottom | INT | 00–4096 | — |
| padding_left | INT | 00–4096 | — |
| padding_right | INT | 00–4096 | — |
| crop_padding | INT | 200–4096 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |