Auto Background Mask
The person mask's quieter twin, and the two uses it's genuinely good for
- image
- background_mask
This is the Auto Person Mask node with one line changed: instead of returning the person's mask, it returns the background. Same machinery, same model dropdown, same dependency gotcha - just inverted output. That sounds like a small thing, but a background mask is the more useful half for a lot of workflows, because it's the half you usually want to edit. Swap the background, blur the background for depth, or region-prompt the environment without touching the subject. That's this node's whole job.
How it works
It runs the same rembg / U2-Net segmentation as its sibling and then inverts the alpha - where the person was, the background mask is black; everywhere else, white. All the settings carry over unchanged: model (u2net, u2netp, u2net_human_seg, silueta), alpha_matting for better-but-slower edges with the three matting thresholds, and post_process_mask for morphological cleanup. The output is a single background_mask MASK - that's it, one output, no masked_image.
The two uses worth knowing
- Inpaint the background. Person mask → inpaint where the person is. Background mask → inpaint where the person isn't, which is how you do things like "change the street behind her" while keeping the subject pixel-identical.
- Depth-of-field fakes. Blur the masked background region slightly, keep the person sharp, and you get a cheap faux-bokeh that reads as more photographic.
Both are legitimate, and both are exactly where a background mask beats a person mask - because you'd otherwise have to invert the person mask yourself and hope the edges survive the round trip.
Installing it
Same pack, same install. The critical detail is the same one that bites its sibling: the README doesn't list rembg, but this node can't run without it.
pip install rembg
First run downloads the U2-Net ONNX weights, so the first execution stalls for a bit. Then restart ComfyUI if you installed it cold, and hard-refresh the browser.
Honest take
The quality caveat from the person-mask article applies verbatim: U2-Net is a 2020 model and its edges are acceptable, not exceptional. Hair against a busy background still eats it. For quick background swaps and the two uses above, that's usually tolerable. If you need hair-grade edges, a BiRefNet-based node will beat this on the same image - this one is the convenience store, not the butcher. It's a fine node to keep in your graph for the fast path, and it's genuinely handy that the inverted mask comes free instead of you having to build the inversion yourself.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | 4 options: u2net, u2netp, u2net_human_seg, silueta | |
| alpha_mattingopt | BOOLEAN | false | Better edge quality but slower |
| alpha_matting_foreground_thresholdopt | INT | 2400–255 | — |
| alpha_matting_background_thresholdopt | INT | 100–255 | — |
| alpha_matting_erode_sizeopt | INT | 100–50 | — |
| post_process_maskopt | BOOLEAN | false | Clean up mask with morphological operations |
| show_debugopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| background_mask | MASK | — |