Nodes/ComfyUI-ArchAi3d-Qwen/🎯 SAM3 Segment (Low VRAM)
ComfyUI Node

🎯 SAM3 Segment (Low VRAM)

Real-time SAM3 segmentation that remembers it's on a low-VRAM card

By amir84ferdosΒ·Created 11 months agoΒ·Updated 5 months agoΒ· 70
🎯 SAM3 Segment (Low VRAM)
  • image
  • IMAGE
  • MASK
  • MASK_IMAGE
β—„namesam3_segmentβ–Ί
β—„promptβ–Ί
β—„confidence_threshold0.50β–Ί
β—„segment_pick0β–Ί
β—„use_cachetrueβ–Ί
β—„mask_blur0β–Ί
β—„mask_offset0β–Ί
β—„invert_outputfalseβ–Ί
β—„backgroundAlphaβ–Ί
β—„background_color#222222β–Ί
β—„deviceAutoβ–Ί
β—„compile_modelfalseβ–Ί

SAM3 is Meta's third Segment Anything model, and the headline that got people's attention was "real time." The older SAM models were a 0.5–3 second per-image affair; SAM3 (late 2025) segments fast enough that you stop thinking about the mask step as a wait. This node wraps it for ComfyUI with an explicit low-VRAM strategy: it downloads the weights, runs them, then unloads the model after every single execution. If you've ever had a segmentation node silently eat your VRAM and then OOM the sampler ten minutes later, you'll recognize why that design choice is the whole selling point here.

How it works

You give it an image and a prompt - a plain-English description of what to segment ("the sofa", "the red chair") - and it returns a mask of every object matching that description. SAM3 is prompt-driven, so no training, no boxes, no clicks: describe, segment. The model weights (sam3.pt) auto-download from HuggingFace into ComfyUI/models/sam3/ on first run, so the first execution is slow and downloads, and everything after is a warm run.

The low-VRAM machinery is visible in the inputs:

  • use_cache (default True) - results are hashed and cached to disk, so re-running the same image+prompt skips inference entirely.
  • device - Auto/CPU/GPU. CPU is there because sometimes it's better to spend a few seconds segmenting than to fight a 6GB card for space.
  • compile_model - optional torch.compile for speed. First run compiles (~60s), then the compiled kernels are cached per GPU architecture for instant reuse. Nice on a 4090, pointless on a laptop.

Inputs that matter

  • prompt - the text description. "car" gets the car; "the car on the left" is usually better than a giant general segment.
  • confidence_threshold - 0.5 default. Crank toward 0.7 if you're getting noisy extra regions; drop toward 0.3 if objects are being missed.
  • segment_pick - 0 merges all matched segments into one mask; 1+ picks a single segment by confidence rank. Set to 1 if you only want the primary object, not its siblings.
  • mask_blur / mask_offset - feather and shrink/expand the final mask, handy before feeding it to a detailer or inpaint node.
  • invert_output - flip the mask; useful when you want everything except the segment.
  • background - the IMAGE output can be cut onto transparent (Alpha) or a solid background_color (default #222222) if you need a clean cutout preview.

Outputs: IMAGE (segmented/backgrounded image), MASK (the raw mask for inpainting or conditioning), MASK_IMAGE (mask visualized as an image).

Install

Pack install plus the SAM3-specific dependencies:

cd ComfyUI/custom_nodes
git clone https://github.com/amir84ferdos/ComfyUI-ArchAi3d-Qwen.git
cd ComfyUI-ArchAi3d-Qwen && pip install -r requirements.txt

The SAM3 deps (sam3, einops, pycocotools, scikit-image, and friends) are in requirements.txt, but if you'd rather not install every optional group in this giant pack, the pack's ArchAi3D_Dependency_Installer node has a "Install SAM3" action that gets just those. Or via ComfyUI Manager β†’ search "ArchAi3d Qwen" β†’ Install β†’ restart.

Caveats

The weights come from a community mirror (1038lab/sam3) rather than Meta's official release - the pack bundled SAM3 code locally instead of depending on another repo, and the mirror is what that bundling resolved to. It works, but be aware you're trusting a third-party weight mirror on first download. Also, the KB's background-removal doc is a reminder that text-prompt segmentation and background removal are different jobs - this is a region finder, so pair it with BiRefNet or an inpaint step for actual background removal.

CategoryArchAi3d/Mask/Segmentation

Inputs (13)

NameTypeDefaultDescription
nameSTRINGsam3_segmentIdentifier name for this input (used by web interface)
imageIMAGEβ€”
promptSTRINGβ€”
confidence_thresholdFLOAT0.500.05–0.95Confidence threshold for segmentation
segment_pickINT00–1280 = merge all segments, 1+ = pick specific segment by confidence rank
use_cacheBOOLEANtrueUse disk cache to avoid reprocessing identical inputs
mask_bluroptINT00–64β€”
mask_offsetoptINT0-64–64β€”
invert_outputoptBOOLEANfalseβ€”
backgroundoptCOMBOAlpha2 options: Alpha, Color
background_coloroptSTRING#222222β€”
deviceoptCOMBOAuto3 options: Auto, CPU, GPU
compile_modeloptBOOLEANfalsetorch.compile for faster inference. First run compiles (~60s), cached per GPU arch for instant reuse

Outputs (3)

NameTypeDescription
IMAGEIMAGEβ€”
MASKMASKβ€”
MASK_IMAGEIMAGEβ€”