ComfyUI Node

💀Image RMBG

Background removal inside ComfyUI with BiRefNet-class edges

By S4MUEL-404·Created about a year ago·Updated 10 months ago· 4
💀Image RMBG
  • image
  • image
  • mask
  • info
sensitivity1.00
process_res1024
output_formatRGBA (Transparent)
edge_methodGaussian
feather_radius0.0
mask_blur0
mask_offset0
quality_modeBalanced
batch_size1
alpha_mattingfalse
background_color#FFFFFF
invert_outputfalse

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 Only to inspect the alpha, or Original + Background which composites onto whatever color you set in background_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, or Smart Blur. Alpha Matting is 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), and alpha_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/ has config.json, model.safetensors, birefnet.py, BiRefNet_config.py. The node logs exactly which files it wants.
  • Hairy edges still messy - bump process_res to 1536/2048 and try Alpha Matting as edge_method. Hair is the failure mode no model fully solves; this is where you spend the quality budget.
  • Halo around the subject - negative mask_offset and a touch of feather_radius.
  • Background not actually removed - check output_format: Foreground Only gives a black background, and Original + Background keeps the original behind background_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.

Category💀S4Tool

Inputs (13)

NameTypeDefaultDescription
imageIMAGEInput image to be processed for background removal
sensitivityoptFLOAT1.000.1–1.5Mask detection sensitivity (0.0=aggressive, 1.0=conservative)
process_resoptCOMBO1024Processing resolution - higher = better quality but slower
output_formatoptCOMBORGBA (Transparent)Output format: RGBA=transparent background, Foreground=black background, Mask=mask preview, Original+Background=replace background with color
edge_methodoptCOMBOGaussianEdge refinement technique for smoother transitions
feather_radiusoptFLOAT0.00–20Soft feathering radius for natural edges (0=sharp)
mask_bluroptINT00–32Gaussian blur radius for mask smoothing
mask_offsetoptINT0-32–32Expand (+) or contract (-) mask boundaries
quality_modeoptCOMBOBalancedProcessing quality vs speed trade-off
batch_sizeoptINT11–8Process multiple images simultaneously for efficiency
alpha_mattingoptBOOLEANfalseAdvanced alpha matting for hair and fine details
background_coloroptSTRING#FFFFFFBackground color: Used by 'Original + Background' and 'Foreground Only' formats. RGBA format always outputs transparent background.
invert_outputoptBOOLEANfalseInvert the mask output (foreground<->background)

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
infoSTRING