🎭 高质量背景移除
A one-node cutout with feather control — rembg, minus the command line
- image
- image
- mask
AdvancedBackgroundRemoval (🎭 高质量背景移除) is this pack's cutout node: feed it an image, get back the subject with the background knocked out plus the alpha mask. Under the hood it's the rembg library - the same engine behind a thousand "one-click background remover" web apps - wrapped so it runs inside a ComfyUI graph, with a bit of extra edge cleanup bolted on.
It's the right tool when you need a foreground layer out of an existing image: product shots on white, a subject to composite onto a new background, or a clean mask to route into an inpainting workflow. It is not the cutting edge of matting - more on that below - but for a solid subject against a contrasting background it's effectively solved, fast, and runs on CPU.
How it works
The node uses rembg's segmentation sessions to label each pixel foreground or background. The model dropdown exposes two of rembg's weights: u2net (the general-purpose salient-object detector, the historical default) and u2net_human_seg (optimized for people - the one to reach for on portraits). The first time you use a model, rembg downloads its weights (roughly 170 MB for u2net) to a local cache, so the first run is slow and the next ones aren't.
Each image in the batch goes through the segmenter, then optional post-processing: mask_blur applies a Gaussian blur to the alpha channel and edge_feather dilates/feathers the edges in 0–10 pixel steps. The result is split into an RGB image and an alpha MASK, which is the bit you'll want for compositing elsewhere. If rembg isn't installed, the node degrades to a heuristic fallback rather than crashing.
Inputs and outputs that matter
image- the input. Batch dimension is respected; each frame is processed independently.model-u2net(general) oru2net_human_seg(people). Defaultu2net.alpha_matting- off by default. Enabling it runs rembg's more expensive edge refinement, which helps on hair but is slow and can be unpredictable.post_processing(default on) withedge_feather(default 2) andmask_blur(default 1) - the feather trio that softens the cutout. On a clean product shot you can leave it alone; on wispy edges, feathering hides the hard boundary.
Outputs: image (subject on a transparent background) and mask (the alpha channel as a MASK, ready for inpaint masks or compositing).
Installing it
Same pack install as the rest (ComfyUI Manager → "Kontext Super Prompt" or git clone https://github.com/aiaiaikkk/super-prompt-canvas), plus the dependency Manager will not pull automatically:
pip install rembg onnxruntime
rembg is imported lazily - the pack's requirements.txt only lists requests and numpy - so the node appears in the menu but does nothing useful until you install it.
Where people get burned
The honest caveat, and it's a real one: u2net is the 2020 baseline. The background-removal world has moved on - BiRefNet is the community's current default for hair and semi-transparent material, and modern ComfyUI even ships native background-removal nodes in core. If your subject is a person with flyaway hair against a busy backdrop, this node will give you a choppy edge and you'll wonder why everyone said cutouts were solved. It works great on the easy 80% (solid objects, clean backgrounds, product shots) and you should reach for BiRefNet-based tooling for the hard 20%. Also, remember the fallback path: if rembg is missing you'll silently get a white mask, so check the console if your cutout comes back empty.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | u2net | 2 options: u2net, u2net_human_seg |
| alpha_matting | BOOLEAN | false | — |
| post_processing | BOOLEAN | true | — |
| edge_featheropt | INT | 20–10 | — |
| mask_bluropt | FLOAT | 1.000–5 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |