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

Segmentation V2 (RMBG)

Segmentation V2 (RMBG)

By 1038lab·Created 2 years ago·Updated 11 days ago· 2,057
Segmentation V2 (RMBG)
  • image
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
prompt
sam_model
dino_model
threshold0.35
mask_blur0
mask_offset0
invert_outputfalse
backgroundAlpha

SegmentV2 is the refined version of the pack's text-prompted object selector: type what you want, get a clean mask of it. It's the same proven engine as the original Segment node - GroundingDINO turns your words into bounding boxes, SAM turns those boxes into precise masks - with tidied-up defaults and batch-image support added. If you're choosing between the two SAM+GroundingDINO nodes in this pack, this is the one to start with.

The reason it's two models under the hood: GroundingDINO understands language and locates the object; SAM (Segment Anything) draws the exact outline. That split is what lets you pick one specific thing out of a busy image by describing it - the woman's handbag, red umbrella, dog - which a plain background remover can't do. That's the point of this node. It's targeted masking for feeding inpainting, detailers, or regional edits, not background stripping (use RMBG or BiRefNet for that).

Inputs that matter: prompt is your text query and accepts both tag lists (cat, dog) and natural sentences. sam_model selects the SAM checkpoint - sam_vit_h (2.56GB, highest quality) down to sam_vit_b (375MB, light), plus the sam_hq_ high-quality variants that give crisper edges at a similar size; grab an HQ one when you're masking hair or fine detail. dino_model is the detector, GroundingDINO_SwinT_OGC (694MB, default) or the heavier GroundingDINO_SwinB (938MB). threshold sits at 0.35 by default here (V1 defaulted to 0.3) - nudge it down toward 0.25 to catch more, up toward 0.5 to be selective and avoid grabbing the wrong object. Then the usual finishers: mask_blur, mask_offset, invert_output, background, and background_color. Outputs are IMAGE, MASK, and MASK_IMAGE, with MASK being the one you route into whatever comes next.

Install is the pack routine: "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. SAM checkpoints land in ComfyUI/models/SAM/ and GroundingDINO in ComfyUI/models/grounding-dino/, auto-downloaded the first time you run a given combination.

The near-universal first-run problem: a 401 error while initializing GroundingDINO. It looks like an auth failure but it isn't - the repos are public and download anonymously. The culprit is a leftover Hugging Face token. Delete the cached token (%USERPROFILE%\.cache\huggingface\token, plus .huggingface\token if it's there), clear any HF_TOKEN / HUGGINGFACE_TOKEN env var, and re-run. This is the single most common reason a fresh install of these segmentation nodes won't fire.

Where SegmentV2 fits against its siblings: it's the mature SAM+DINO option, and the batch support makes it the better pick if you're running a folder of images through the same prompt. The SAM2 and SAM3 nodes use newer segmenters - SAM3 in particular can do text-to-mask without the separate DINO step and is often more accurate - but SAM3 depends on Triton, which is a real headache on Windows, so SegmentV2 is the dependable everywhere-it-works choice. And the recurring note for the whole family: don't reach for any of these just to delete a background. That's a lot of detector machinery for something a single-model remover handles in one pass. SegmentV2 is for when you need that one object, by name.

Category🧪AILab/🧽RMBG

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
promptSTRINGEnter the object or scene you want to segment. Use tag-style or natural language for more detailed prompts.
sam_modelCOMBO6 options: sam_vit_h (2.56GB), sam_vit_l (1.25GB), sam_vit_b (375MB), sam_hq_vit_h (2.57GB), sam_hq_vit_l (1.25GB), sam_hq_vit_b (379MB)
dino_modelCOMBO2 options: GroundingDINO_SwinT_OGC (694MB), GroundingDINO_SwinB (938MB)
thresholdoptFLOAT0.350.05–0.95Adjust mask detection strength (higher = more strict)
mask_bluroptINT00–64Apply Gaussian blur to mask edges (0 = disabled)
mask_offsetoptINT0-64–64Expand/Shrink mask boundary (positive = expand, negative = shrink)
invert_outputoptBOOLEANfalseInvert the mask output
backgroundoptCOMBOAlpha2 options: Alpha, Color
background_coloroptCOLORCODE#222222Choose background color (Alpha = transparent)

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKMASK
MASK_IMAGEIMAGE