ComfyUI custom nodes for Meta's SAM 3 (Segment Anything with Concepts).
SAM 3 enables open-vocabulary text-based segmentation - segment objects using natural language prompts like "person", "red car", "shoe" without manual clicking or drawing.
- 🎯 Text-based segmentation: Use natural language to describe what to segment
- 🔀 Multi-class support: Comma-separated prompts like
"person,car,dog" - 🎭 Instance merging: All detected instances automatically merged
- 🖼️ Dual outputs: Mask + masked image
- ⚡ GPU acceleration: bf16/fp16/fp32 precision support
- 📦 Auto-download: Model downloads from Hugging Face automatically
Search for ComfyUI-segment-anything-3 in ComfyUI Manager and install.
cd ComfyUI/custom_nodes/
git clone --recursive https://github.com/wzyfromhust/ComfyUI-segment-anything-3.git
cd ComfyUI-segment-anything-3Note: Use --recursive to include SAM2 and SAM3 submodules.
Loads the SAM3 model.
Parameters:
device: cuda/cpuprecision: bf16 (default), fp16, fp32confidence_threshold: 0.0-1.0 (default: 0.5)
Segments objects using text prompts.
Parameters:
sam3_model: Model from loaderimage: Input imagetext_prompt:- Single:
"person" - Multiple:
"person,shoe,car" - Descriptive:
"red car","person wearing blue"
- Single:
keep_model_loaded: Keep in VRAM (default: false)
Outputs:
mask: Segmentation mask [1, H, W]image: Masked image [1, H, W, C]
LoadImage → Sam3Segmentation → PreviewImage
↑
(Down)Load SAM3 Model
Text prompt examples:
"person"- All people"person,shoe"- People and shoes (merged)"red car"- Red cars only"person wearing blue"- People in blue clothes
Model path: /root/ComfyUI/models/sam3/sam3.pt
Auto-download: If model doesn't exist, it downloads from Hugging Face automatically.
Requirements:
huggingface-cli login
# Accept terms at https://huggingface.co/facebook/sam3Model specs:
- Size: ~850 MB
- Parameters: 848M
text_prompt = "person" # Segments all peopletext_prompt = "person,car,dog" # Segments people, cars, and dogstext_prompt = "red car" # Only red cars
text_prompt = "person wearing blue" # People in blue- Built on SAM3 official implementation
- Strictly aligned with official inference pipeline
- Uses
torch.autocastwith bf16 for optimal performance - Supports multi-prompt inference with automatic merging
- ComfyUI
- PyTorch with CUDA (for GPU acceleration)
- Hugging Face account (for model download)
- SAM3 Official - Meta AI Research
- ComfyUI SAM2 - SAM2 integration reference
This project integrates:
- SAM3: Apache 2.0 License
- SAM2: Apache 2.0 License