中文文档 | English
Simple implementation of ByteDance Sa2VA nodes for ComfyUI.
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-Sa2VA-XJ.git
cd ComfyUI-Sa2VA-XJ
pip install -r requirements.txt
Optional:
pip install bitsandbytes # For 8-bit quantization
pip install flash-attn --no-build-isolation # For flash attention
pip install opencv-python # For morphological operations
Restart ComfyUI after installation.
You can download models manually (recommended) or let the node auto-download from HuggingFace on first use.
Manual download gives you control over model locations, enables offline use, and avoids duplicate downloads.
Directory Structure:
ComfyUI/models/
├── sa2va/
│ ├── ByteDance/
│ │ ├── Sa2VA-Qwen3-VL-4B/
│ │ ├── Sa2VA-InternVL3-2B/
│ │ ├── Sa2VA-Qwen2_5-VL-3B/
│ │ ├── Sa2VA-Qwen2_5-VL-7B/
│ │ ├── Sa2VA-InternVL3-8B/
│ │ └── Sa2VA-InternVL3-14B/
│ └── (or without ByteDance/ prefix)
└── vitmatte/
└── hustvl/
└── vitmatte-small-composition-1k/
Method 1: Using huggingface-cli (Recommended)
# Install HuggingFace CLI
pip install -U huggingface_hub
# Download Sa2VA model (example: Qwen3-VL-4B)
huggingface-cli download ByteDance/Sa2VA-Qwen3-VL-4B \
--local-dir ComfyUI/models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B
# Download VITMatte model (for V2 node)
huggingface-cli download hustvl/vitmatte-small-composition-1k \
--local-dir ComfyUI/models/vitmatte/hustvl/vitmatte-small-composition-1k
Method 2: Using git-lfs
# Install git-lfs
git lfs install
# Download Sa2VA model
cd ComfyUI/models/sa2va/ByteDance
git clone https://huggingface.co/ByteDance/Sa2VA-Qwen3-VL-4B
# Download VITMatte model
cd ComfyUI/models/vitmatte/hustvl
git clone https://huggingface.co/hustvl/vitmatte-small-composition-1k
Alternative Directory Structure:
You can also download without the organization prefix:
# Download directly to model name folder
huggingface-cli download ByteDance/Sa2VA-Qwen3-VL-4B \
--local-dir ComfyUI/models/sa2va/Sa2VA-Qwen3-VL-4B
Both structures are supported:
models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/ ✅models/sa2va/Sa2VA-Qwen3-VL-4B/ ✅Models will auto-download from HuggingFace to ~/.cache/huggingface/hub/ on first use if not found locally.
Note: This may take time depending on your internet connection and will use HuggingFace's cache directory.
Plan your storage accordingly:
| Model | Download Size | Disk Size (Installed) | VRAM (fp16) | VRAM (8-bit) |
|---|---|---|---|---|
| Sa2VA Models | ||||
| InternVL3-2B | ~4GB | ~4.5GB | ~6GB | ~4GB |
| Qwen2_5-VL-3B | ~6GB | ~6.5GB | ~8GB | ~5GB |
| Qwen3-VL-4B (default) | ~8GB | ~9GB | ~10GB | ~6GB |
| Qwen2_5-VL-7B | ~14GB | ~15GB | ~16GB | ~10GB |
| InternVL3-8B | ~16GB | ~17GB | ~18GB | ~11GB |
| InternVL3-14B | ~28GB | ~30GB | ~30GB | ~18GB |
| VITMatte Model | ||||
| vitmatte-small-composition-1k | ~300MB | ~350MB | +2GB | +2GB |
Storage Tips:
Inputs:
model_name: Model selection (default: Qwen3-VL-4B)image: Input imagesegmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.5)use_8bit: 8-bit quantization (default: True)use_flash_attn: Flash attention (default: True)unload: Unload model after inference (default: True)morph: Morphological operation (none/opening/closing/erode/dilate)erode_kernel, dilate_kernel, iterations: Morphology parametersOutputs:
text_output: Text descriptionmasks: Segmentation masksVITMatte-based post-processing for smooth alpha mattes.
Inputs:
model_name: Model selection (default: Qwen3-VL-4B)image: Input imagesegmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.5)use_8bit: 8-bit quantization (default: True)use_flash_attn: Flash attention (default: True)unload: Unload model after inference (default: True)process_detail: Enable VITMatte (default: True)detail_erode: Trimap erosion size (1-255, default: 6)detail_dilate: Trimap dilation size (1-255, default: 6)black_point: Histogram black point (0.01-0.98, default: 0.15)white_point: Histogram white point (0.02-0.99, default: 0.99)max_megapixels: Max resolution (0.5-10.0, default: 2.0)Outputs:
text_output: Text descriptionmasks: Alpha mattesV1 vs V2:
Process video frames or image batches.
Inputs:
model_name: Model selectionimages: Input frames (batch)segmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.7)use_8bit, use_flash_attn, unload: Same as V1morph, erode_kernel, dilate_kernel, iterations: Morphology parametersOutputs:
text_output: Video descriptionmasks: Segmentation masks for all framesAll models are from ByteDance's Sa2VA family:
| Model | Parameters | Notes |
|---|---|---|
| InternVL3-2B | 2B | Smallest, fastest |
| Qwen2_5-VL-3B | 3B | Good for low VRAM |
| Qwen3-VL-4B | 4B | Default - Best balance |
| Qwen2_5-VL-7B | 7B | Higher quality |
| InternVL3-8B | 8B | Advanced features |
| InternVL3-14B | 14B | Best quality, requires 24GB+ VRAM |
See Model Installation section for download instructions and VRAM requirements.
"transformers >= 4.57.0 required"
pip install transformers>=4.57.0 --upgrade
"No module named 'qwen_vl_utils'"
pip install qwen_vl_utils
Model Downloads
The node will log where it's loading models from:
Found local Sa2VA model at: /path/to/model - Using local model ✅Local model not found. Will download from HuggingFace: ... - Auto-downloading from HFTo verify model installation:
# Check if Sa2VA models exist
ls -la ComfyUI/models/sa2va/
# Check if VITMatte model exists
ls -la ComfyUI/models/vitmatte/
# Each model directory should contain config.json
ls ComfyUI/models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/config.json
Slow First Load
"CUDA Out of Memory"
use_8bitunload = Truemax_megapixels (V2 only)"No masks generated"
threshold (try 0.3-0.7)The nodes follow ComfyUI's standard model loading pattern:
ComfyUI/models/sa2va/ and ComfyUI/models/vitmatte/~/.cache/huggingface/hub/ if not found locallymodels/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/models/sa2va/Sa2VA-Qwen3-VL-4B/Benefits:
Sa2VA outputs raw sigmoid probabilities (0.0-1.0) instead of binary masks. The threshold parameter controls binarization.
Quantizes language model backbone while skipping vision components (visual, grounding_encoder, text_hidden_fcs) to avoid errors.
VITMatte is a Vision Transformer-based alpha matting model that produces smooth, professional-quality masks.
Why VITMatte produces better masks:
Processing pipeline:
Trade-offs:
MIT
102 followers · starred Feb 2026
中文文档 | English
Simple implementation of ByteDance Sa2VA nodes for ComfyUI.
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-Sa2VA-XJ.git
cd ComfyUI-Sa2VA-XJ
pip install -r requirements.txt
Optional:
pip install bitsandbytes # For 8-bit quantization
pip install flash-attn --no-build-isolation # For flash attention
pip install opencv-python # For morphological operations
Restart ComfyUI after installation.
You can download models manually (recommended) or let the node auto-download from HuggingFace on first use.
Manual download gives you control over model locations, enables offline use, and avoids duplicate downloads.
Directory Structure:
ComfyUI/models/
├── sa2va/
│ ├── ByteDance/
│ │ ├── Sa2VA-Qwen3-VL-4B/
│ │ ├── Sa2VA-InternVL3-2B/
│ │ ├── Sa2VA-Qwen2_5-VL-3B/
│ │ ├── Sa2VA-Qwen2_5-VL-7B/
│ │ ├── Sa2VA-InternVL3-8B/
│ │ └── Sa2VA-InternVL3-14B/
│ └── (or without ByteDance/ prefix)
└── vitmatte/
└── hustvl/
└── vitmatte-small-composition-1k/
Method 1: Using huggingface-cli (Recommended)
# Install HuggingFace CLI
pip install -U huggingface_hub
# Download Sa2VA model (example: Qwen3-VL-4B)
huggingface-cli download ByteDance/Sa2VA-Qwen3-VL-4B \
--local-dir ComfyUI/models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B
# Download VITMatte model (for V2 node)
huggingface-cli download hustvl/vitmatte-small-composition-1k \
--local-dir ComfyUI/models/vitmatte/hustvl/vitmatte-small-composition-1k
Method 2: Using git-lfs
# Install git-lfs
git lfs install
# Download Sa2VA model
cd ComfyUI/models/sa2va/ByteDance
git clone https://huggingface.co/ByteDance/Sa2VA-Qwen3-VL-4B
# Download VITMatte model
cd ComfyUI/models/vitmatte/hustvl
git clone https://huggingface.co/hustvl/vitmatte-small-composition-1k
Alternative Directory Structure:
You can also download without the organization prefix:
# Download directly to model name folder
huggingface-cli download ByteDance/Sa2VA-Qwen3-VL-4B \
--local-dir ComfyUI/models/sa2va/Sa2VA-Qwen3-VL-4B
Both structures are supported:
models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/ ✅models/sa2va/Sa2VA-Qwen3-VL-4B/ ✅Models will auto-download from HuggingFace to ~/.cache/huggingface/hub/ on first use if not found locally.
Note: This may take time depending on your internet connection and will use HuggingFace's cache directory.
Plan your storage accordingly:
| Model | Download Size | Disk Size (Installed) | VRAM (fp16) | VRAM (8-bit) |
|---|---|---|---|---|
| Sa2VA Models | ||||
| InternVL3-2B | ~4GB | ~4.5GB | ~6GB | ~4GB |
| Qwen2_5-VL-3B | ~6GB | ~6.5GB | ~8GB | ~5GB |
| Qwen3-VL-4B (default) | ~8GB | ~9GB | ~10GB | ~6GB |
| Qwen2_5-VL-7B | ~14GB | ~15GB | ~16GB | ~10GB |
| InternVL3-8B | ~16GB | ~17GB | ~18GB | ~11GB |
| InternVL3-14B | ~28GB | ~30GB | ~30GB | ~18GB |
| VITMatte Model | ||||
| vitmatte-small-composition-1k | ~300MB | ~350MB | +2GB | +2GB |
Storage Tips:
Inputs:
model_name: Model selection (default: Qwen3-VL-4B)image: Input imagesegmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.5)use_8bit: 8-bit quantization (default: True)use_flash_attn: Flash attention (default: True)unload: Unload model after inference (default: True)morph: Morphological operation (none/opening/closing/erode/dilate)erode_kernel, dilate_kernel, iterations: Morphology parametersOutputs:
text_output: Text descriptionmasks: Segmentation masksVITMatte-based post-processing for smooth alpha mattes.
Inputs:
model_name: Model selection (default: Qwen3-VL-4B)image: Input imagesegmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.5)use_8bit: 8-bit quantization (default: True)use_flash_attn: Flash attention (default: True)unload: Unload model after inference (default: True)process_detail: Enable VITMatte (default: True)detail_erode: Trimap erosion size (1-255, default: 6)detail_dilate: Trimap dilation size (1-255, default: 6)black_point: Histogram black point (0.01-0.98, default: 0.15)white_point: Histogram white point (0.02-0.99, default: 0.99)max_megapixels: Max resolution (0.5-10.0, default: 2.0)Outputs:
text_output: Text descriptionmasks: Alpha mattesV1 vs V2:
Process video frames or image batches.
Inputs:
model_name: Model selectionimages: Input frames (batch)segmentation_prompt: Text descriptionthreshold: Binary threshold (0.0-1.0, default: 0.7)use_8bit, use_flash_attn, unload: Same as V1morph, erode_kernel, dilate_kernel, iterations: Morphology parametersOutputs:
text_output: Video descriptionmasks: Segmentation masks for all framesAll models are from ByteDance's Sa2VA family:
| Model | Parameters | Notes |
|---|---|---|
| InternVL3-2B | 2B | Smallest, fastest |
| Qwen2_5-VL-3B | 3B | Good for low VRAM |
| Qwen3-VL-4B | 4B | Default - Best balance |
| Qwen2_5-VL-7B | 7B | Higher quality |
| InternVL3-8B | 8B | Advanced features |
| InternVL3-14B | 14B | Best quality, requires 24GB+ VRAM |
See Model Installation section for download instructions and VRAM requirements.
"transformers >= 4.57.0 required"
pip install transformers>=4.57.0 --upgrade
"No module named 'qwen_vl_utils'"
pip install qwen_vl_utils
Model Downloads
The node will log where it's loading models from:
Found local Sa2VA model at: /path/to/model - Using local model ✅Local model not found. Will download from HuggingFace: ... - Auto-downloading from HFTo verify model installation:
# Check if Sa2VA models exist
ls -la ComfyUI/models/sa2va/
# Check if VITMatte model exists
ls -la ComfyUI/models/vitmatte/
# Each model directory should contain config.json
ls ComfyUI/models/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/config.json
Slow First Load
"CUDA Out of Memory"
use_8bitunload = Truemax_megapixels (V2 only)"No masks generated"
threshold (try 0.3-0.7)The nodes follow ComfyUI's standard model loading pattern:
ComfyUI/models/sa2va/ and ComfyUI/models/vitmatte/~/.cache/huggingface/hub/ if not found locallymodels/sa2va/ByteDance/Sa2VA-Qwen3-VL-4B/models/sa2va/Sa2VA-Qwen3-VL-4B/Benefits:
Sa2VA outputs raw sigmoid probabilities (0.0-1.0) instead of binary masks. The threshold parameter controls binarization.
Quantizes language model backbone while skipping vision components (visual, grounding_encoder, text_hidden_fcs) to avoid errors.
VITMatte is a Vision Transformer-based alpha matting model that produces smooth, professional-quality masks.
Why VITMatte produces better masks:
Processing pipeline:
Trade-offs:
MIT
102 followers · starred Feb 2026