ComfyUI-SDMatte
SDMatte is an interactive image matting method based on stable diffusion, which supports three types of visual prompts (points, boxes, and masks) for accurately extracting target objects from natural images.
Package profile
- Status
- Verified
- Publisher
- @flybirdxx
- Source
- GitHub
README
ComfyUI-SDMatte
English | 简体中文
ComfyUI custom nodes plugin based on SDMatte for interactive image matting.
🚀 Quick Start
📺 Video Tutorial: ComfyUI-SDMatte Tutorial
🔧 Example Workflow: Superior Image Cropping and Mask Refinement Workflow
💡 Recommended: Watch the video tutorial first to understand the usage, then download the workflow for practice
📖 Introduction
SDMatte is an interactive image matting method based on Stable Diffusion, developed by the vivo Camera Research team and accepted by ICCV 2025. This method leverages the powerful priors of pre-trained diffusion models and supports multiple visual prompts (points, boxes, masks) for accurately extracting target objects from natural images.
This plugin integrates SDMatte into ComfyUI, providing a simple and easy-to-use node interface focused on trimap-guided matting functionality with built-in VRAM optimization strategies.
🖼️ Examples
Matting Results
Example workflow demonstrating SDMatte's high-precision matting capabilities with trimap guidance.
✨ Features
- 🎯 High-Precision Matting: Based on powerful diffusion model priors, capable of handling complex edge details
- 🖼️ Trimap Guidance: Supports trimap-guided precise matting
- 🚀 VRAM Optimization: Built-in mixed precision, attention slicing, and other memory optimization strategies
- 🔧 ComfyUI Integration: Fully compatible with ComfyUI workflow system
- 📥 Automatic Model Download: Automatically downloads model weights on first use
- 📱 Flexible Sizes: Supports multiple inference resolutions (512-1024px)
🛠️ Installation
1. Download Plugin
Place this plugin in the ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/
git clone https://github.com/flybirdxx/ComfyUI-SDMatte.git
2. Install Dependencies
ComfyUI will automatically install the dependencies in requirements.txt on startup:
- diffusers
- timm
- einops
- lazyconfig
- safetensors
3. Automatic Component Download
The plugin automatically downloads required config files, no manual action needed.
SDMatte is built on top of Stable Diffusion 2.1. On first use, it automatically downloads necessary config files from Hugging Face (no model weights):
- Auto-downloads to:
ComfyUI/models/diffusers/stable-diffusion-2-1-base/ - Downloads only config files: config.json, tokenizer files, etc.
- No large weight files downloaded, saving disk space
If you need to manually download the complete Stable Diffusion 2.1 model:
# Navigate to diffusers directory
cd ComfyUI/models/diffusers/
# Download Stable Diffusion 2.1 base model
# Method 1: Using huggingface_hub
pip install huggingface_hub
huggingface-cli download stabilityai/stable-diffusion-2-1 --local-dir stable-diffusion-2-1-base
# Method 2: Using git lfs (if installed)
git lfs install
git clone https://huggingface.co/stabilityai/stable-diffusion-2-1 stable-diffusion-2-1-base
4. Automatic Model Download
SDMatte model weights will be downloaded automatically.
The first time you use the Apply SDMatte node, it will automatically check for and download the necessary SDMatte model weights from Hugging Face. The models will be stored in:
ComfyUI/models/SDMatte/
You can select between the standard (SDMatte.safetensors) and enhanced (SDMatte_plus.safetensors) versions directly within the node.
4. Restart ComfyUI
Restart ComfyUI to lo
Nodes in this pack
1 node
Nodes in this pack
1 node- SDMatteApply
Sources
3 sources
Sources
3 sourcesVerified Oct 6
Verified Oct 6
Source excerpts
1 excerpt
Source excerpts
1 excerptSource context: Repo flybirdxx/ComfyUI-SDMatte
