💀Image RMBG
Background removal inside ComfyUI with BiRefNet-class edges
- image
- image
- mask
- info
Background removal is the most commoditized operation in this whole ecosystem, and the quality bar moved years ago from "can it find the subject" to "can it survive hair." 💀Image RMBG gets you there without leaving the graph: it's a single node in the S4Tool-Image pack that runs a BiRefNet-family model - specifically the RMBG-2.0 weights - and hands you a transparent PNG, a mask, or a composited cutout, depending on what you ask for.
If you've used ComfyUI's core BiRefNet support or a rembg workflow, this will feel familiar: feed an image, get an alpha. What distinguishes this node is how much of the trim work it absorbs. The model does the hard segmentation, and then the node gives you feathering, blur, edge erosion/dilation, alpha matting, and output-format control - so the "tidy up the edges" step that usually needs extra nodes is all right here.
The inputs that matter
The only required input is image. Everything else is optional and most of it has sane defaults:
output_format- the one you'll set first.RGBA (Transparent)(default) for a cutout,Foreground Only(black background),Mask Onlyto inspect the alpha, orOriginal + Backgroundwhich composites onto whatever color you set inbackground_color.process_res- processing resolution, 256 to 2048, default 1024. Higher is better quality and slower; if the result has chunky edges, this is often the cause, not the model.sensitivity(0.1–1.5, default 1) - the tooltip calls it "0.0=aggressive, 1.0=conservative." Low it when the subject is being swallowed, raise it when background is leaking in.edge_method- edge refinement:Gaussian,Guided Filter,Alpha Matting, orSmart Blur.Alpha Mattingis the one to try for flyaway hair; it's slower but that's the point.feather_radius,mask_blur,mask_offset- softening, blurring, and grow/shrink for the mask.mask_offset(positive expands, negative contracts) is your quick fix for a halo.quality_mode(Fast/Balanced/High Quality/Ultra),batch_size(up to 8), andalpha_matting(toggle) round out the trade-off controls.
Outputs: image, mask, and an info string that reports what the node did - handy for debugging batches.
Install
It's the same pack install as everything else from S4MUEL-404:
cd ComfyUI/custom_nodes/
git clone https://github.com/S4MUEL-404/ComfyUI-S4Tool-Image.git
pip install -r ComfyUI-S4Tool-Image/requirements.txt
Or ComfyUI Manager → search "S4Tool-Image" → Install → restart.
The RMBG-2.0 model is not bundled with the repo. On first run the node auto-downloads four files (model weights, config, and the BiRefNet Python modules) from the 1038lab/RMBG-2.0 repo on Hugging Face into ComfyUI/models/RMBG/RMBG-2.0/. That's roughly a gigabyte of first-run download, and it needs huggingface_hub available - which the pack's requirements install. If you'd rather grab the files yourself, the node will happily use whatever you drop in that folder.
Troubleshooting
- Model download / "required model files are missing" - check
ComfyUI/models/RMBG/RMBG-2.0/hasconfig.json,model.safetensors,birefnet.py,BiRefNet_config.py. The node logs exactly which files it wants. - Hairy edges still messy - bump
process_resto 1536/2048 and tryAlpha Mattingasedge_method. Hair is the failure mode no model fully solves; this is where you spend the quality budget. - Halo around the subject - negative
mask_offsetand a touch offeather_radius. - Background not actually removed - check
output_format:Foreground Onlygives a black background, andOriginal + Backgroundkeeps the original behindbackground_color.
Bottom line: for cutouts inside ComfyUI this is one of the stronger one-node options, and the edge controls mean you don't have to wire up a separate mask-postprocessing stack. The BiRefNet family is the current default recommendation in this ecosystem for a reason - edges beat the old u2net-era tools on exactly the cases that used to need manual cleanup.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to be processed for background removal | |
| sensitivityopt | FLOAT | 1.000.1–1.5 | Mask detection sensitivity (0.0=aggressive, 1.0=conservative) |
| process_resopt | COMBO | 1024 | Processing resolution - higher = better quality but slower |
| output_formatopt | COMBO | RGBA (Transparent) | Output format: RGBA=transparent background, Foreground=black background, Mask=mask preview, Original+Background=replace background with color |
| edge_methodopt | COMBO | Gaussian | Edge refinement technique for smoother transitions |
| feather_radiusopt | FLOAT | 0.00–20 | Soft feathering radius for natural edges (0=sharp) |
| mask_bluropt | INT | 00–32 | Gaussian blur radius for mask smoothing |
| mask_offsetopt | INT | 0-32–32 | Expand (+) or contract (-) mask boundaries |
| quality_modeopt | COMBO | Balanced | Processing quality vs speed trade-off |
| batch_sizeopt | INT | 11–8 | Process multiple images simultaneously for efficiency |
| alpha_mattingopt | BOOLEAN | false | Advanced alpha matting for hair and fine details |
| background_coloropt | STRING | #FFFFFF | Background color: Used by 'Original + Background' and 'Foreground Only' formats. RGBA format always outputs transparent background. |
| invert_outputopt | BOOLEAN | false | Invert the mask output (foreground<->background) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| info | STRING | — |