Nodes/ComfyUI-RMBG/SAM3 Segmentation (RMBG)
ComfyUI Node Runs on cloud

SAM3 Segmentation (RMBG)

SAM3 Segmentation (RMBG)

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
SAM3 Segmentation (RMBG)
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
prompt
output_modeMerged
confidence_threshold0.50
max_segments0
segment_pick0
mask_blur0
mask_offset0
deviceAuto
invert_outputfalse
unload_modelfalse
backgroundAlpha

SAM3 is the newest and slickest way to say "select that thing" in this pack. You type what you want in plain text - dog, the red car, person on the left - and it hands you a mask of it. No clicking points, no bounding boxes, no separate detector node wired up in front. That's the leap over the older Segment nodes: SAM3 does text-to-mask on its own, where SAM/SAM2 needed GroundingDINO bolted on to turn your words into boxes first. This is targeted selection, not background removal - the difference being that you're grabbing a named object to feed into inpainting, regional editing, or compositing, rather than just cutting foreground from background.

The mechanism: SAM3 is Meta's latest segmentation foundation model, and this node wraps it so the whole detect-then-segment loop happens inside one box. You give it text, it finds every matching thing and masks it. That "every matching thing" part is what the extra controls are for.

The inputs that matter start with prompt - your text query, and it's multiline so you can be specific. confidence_threshold (0.05–0.95, default 0.5) is your precision dial: lower it to catch more (and risk grabbing junk), raise it to only keep confident hits. output_mode is the one people miss - Merged collapses everything it found into a single mask, while Separate keeps each detected instance as its own mask, which is what you want if you're picking out one of several similar objects. That pairs with max_segments (cap how many it returns) and segment_pick (grab just the Nth one). Then the standard finishers: mask_blur, mask_offset, invert_output, and background / background_color if you want a cutout rather than just the mask. There's a device toggle (Auto/CPU/GPU) and a handy unload_model boolean to free VRAM after the run if you're tight. Outputs are IMAGE, MASK, and MASK_IMAGE - and for feeding inpainting or a detailer, MASK is the one you care about.

Install is the pack standard: "Comfyui-RMBG" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt and restart. The SAM3 weights auto-download on first use.

Now the catch, because this one has a real one. On Windows, the SAM3 node wants Triton, and Triton is genuinely painful to get running there. If this node refuses to load on a Windows box, that's almost always why - it's the single most reported problem with it. On Linux you're generally fine. The other classic failure is a 401 error while it tries to pull weights: that's a stale Hugging Face token confusing an anonymous download. Delete the cached token file (%USERPROFILE%\.cache\huggingface\token on Windows), make sure no HF_TOKEN env var is set, and re-run - these are public repos that download without a login.

Should you use it? If you just need a background gone, no - use RMBG or BiRefNet, this is heavier and solving a different problem. But when you need a specific object masked by description and you don't want to wire up a detector, SAM3 is the cleanest option in the pack, and its strong click-through in search suggests plenty of people are hunting for exactly this. Just know there are other SAM3 nodes floating around (the community has a habit of shipping ten versions of the same thing), so if this one won't cooperate on your setup, an alternative pack is a reasonable fallback.

Category🧪AILab/🧽RMBG

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
promptSTRING
output_modeCOMBOMerged2 options: Merged, Separate
confidence_thresholdFLOAT0.500.05–0.95
max_segmentsoptINT00–128
segment_pickoptINT00–128
mask_bluroptINT00–64
mask_offsetoptINT0-64–64
deviceoptCOMBOAuto3 options: Auto, CPU, GPU
invert_outputoptBOOLEANfalse
unload_modeloptBOOLEANfalse
backgroundoptCOMBOAlpha2 options: Alpha, Color
background_coloroptCOLORCODE#222222

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE