Get background mask
Get background mask — the cutout without the cutting
- model
- images
- depths
- masks
- depths
- edges
Most of the time you don't actually want a transparent image - you want the mask that says which pixels are the subject. That's what this node gives you, and it's the right tool whenever the next step in your workflow isn't "save a cutout" but something like "composite onto a new scene," "inpaint behind the subject," or "feed a mask to a mask-aware node." It runs the full pre/post-processing pipeline - normalize, scale to model size, run the network, scale the mask back - and stops before removing or replacing anything.
It sits in the RemBG_SET/Basic category and is the middle child of the pack's three mask nodes: Remove background (does everything), this one (mask with sane defaults), and Get background mask low level (raw, no processing - see its article). If you're reaching for this, you already know you need the mask as a first-class output.
The inputs that matter
model(SET_REMBG) - from any loader in the pack.images(IMAGE) - scaled internally to a model-friendly size.width/height(default 1024, step 32) - the pre-processing size, and the tooltip is explicit: does not affect the final output mask size. Most models accept any multiple of 32; thetrain_w/train_houtputs from a loader node are the right values to wire in here.upscale_method(defaultbicubic) - interpolation for scaling in and out. Bicubic is a fine default.mask_threshold(default 0) - leave at 0 to keep soft fractional values (matter for matte models); set something like 0.5 to force a hard 0/1 mask. A higher value means the model is more confident the pixel is foreground.batch_size- raise for video/batch; the README notes RTX 3060-class boards are better off at 1.depths(optional) - externally computed depth maps, only relevant for PDFNet.out_dtype-float16to halve memory on long video jobs.
Outputs
masks(MASK) - the foreground mask, higher = more confident.depths(MASK) - the depth map (only PDFNet generates one).edges(MASK) - edge map (only DiffDIS generates one).
Wire masks into compositing, inpainting, or anything else that eats a mask.
Install and troubleshooting
Standard pack install: ComfyUI Manager search "Remove Background (SET)", or
cd ComfyUI/custom_nodes
git clone https://github.com/set-soft/ComfyUI-RemoveBackground_SET
pip install -r ComfyUI-RemoveBackground_SET/requirements.txt
ComfyUI 0.3.48+, seconohe >= 1.0.6 (fresh pip install git+https://github.com/set-soft/seconohe.git if it errors). Models land in ComfyUI/models/rembg.
If the mask looks soft at the edges, that's the model being honest, not a bug - raise mask_threshold or switch to a matting checkpoint if you need clean alpha. And remember the wider lesson from the background-removal discourse: a mask that looks great against a grey preview can fall apart composited onto a coloured background, so judge it in context. This node is the pack's polite middle ground - all the control of the advanced node, none of the output clutter.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model | SET_REMBG | The remove background model from `Load RemBG model by file` or any of the `Load XXXXXX model by name` nodes | |
| images | IMAGE | One or more images to process, will be scaled to a size that is good for the model. | |
| width | INT | 10240–16384 | The width of the pre-processing image, does not affect the final output image size |
| height | INT | 10240–16384 | The height of the pre-processing image, does not affect the final output image size |
| upscale_method | COMBO | bicubic | Interpolation method for pre-processing image and post-processing mask |
| mask_threshold | FLOAT | 0.0000–1 | Most models generates masks that contain a value from 0 to 1, but can be any value in between. Matte models can estimate transparency using it. If you need to make the mask 0 or 1, but nothing in between, you can provide a threshold here. Values above it will become 1 and the rest 0. |
| batch_size | INT | 11–256 | How many images to process at once |
| depthsopt | MASK | For models that starts with a depth map | |
| out_dtypeopt | COMBO | AUTO | Data type used for the outputs. `AUTO` means the same as the input.Using `float16` can help when processing videos. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| masks | MASK | The estimated masks, where a higher value means the model estimates it belongs to the foreground with more confidence. |
| depths | MASK | The estimated depth map. Either from the `depths` input or computed. Note this applies only to PDFNet. This is the map generated by `Depth Anything V2` |
| edges | MASK | The estimated edges. This is only generated by the DiffDIS model. |