π― SAM3 Segment (Low VRAM)
Real-time SAM3 segmentation that remembers it's on a low-VRAM card
- image
- IMAGE
- MASK
- MASK_IMAGE
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- optionaltorch.compilefor 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 solidbackground_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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| name | STRING | sam3_segment | Identifier name for this input (used by web interface) |
| image | IMAGE | β | |
| prompt | STRING | β | |
| confidence_threshold | FLOAT | 0.500.05β0.95 | Confidence threshold for segmentation |
| segment_pick | INT | 00β128 | 0 = merge all segments, 1+ = pick specific segment by confidence rank |
| use_cache | BOOLEAN | true | Use disk cache to avoid reprocessing identical inputs |
| mask_bluropt | INT | 00β64 | β |
| mask_offsetopt | INT | 0-64β64 | β |
| invert_outputopt | BOOLEAN | false | β |
| backgroundopt | COMBO | Alpha | 2 options: Alpha, Color |
| background_coloropt | STRING | #222222 | β |
| deviceopt | COMBO | Auto | 3 options: Auto, CPU, GPU |
| compile_modelopt | BOOLEAN | false | torch.compile for faster inference. First run compiles (~60s), cached per GPU arch for instant reuse |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |
| MASK | MASK | β |
| MASK_IMAGE | IMAGE | β |