ComfyUI Extension: xt-matte-toolbox-comfyui-node
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
A ComfyUI custom node for image matting that wraps core matting logic, supporting multiple modes (General/Matting/Portrait), optional ROI control, and outputting foreground RGB, alpha, and mask preview. (Description by CC)
README
XT Matte Toolbox ComfyUI Node
这个仓库是一个独立的 ComfyUI 自定义节点项目,节点名为 XT Matte Cutout。
它复用你原工程里的核心抠图逻辑(src/),只做节点封装,不包含桌面 UI / Photoshop COM / 授权弹窗等 Windows 专属功能。
目录结构
xt-matte-toolbox-comfyui-node/
__init__.py
nodes.py
requirements.txt
README.md
节点能力
输入:
image(IMAGE)model_name(General/Matting/Portrait 等)resolution、semi_transparent、semi_strengthdefringe、defringe_strength- 可选
roi_mask(MASK) 及 ROI 控制参数
输出:
foreground(IMAGE):前景 RGBalpha_mask(MASK):透明度mask_preview(IMAGE):蒙版预览图
安装方式
- 把本仓库克隆到
ComfyUI/custom_nodes:
git clone <your_repo_url> ComfyUI/custom_nodes/xt-matte-toolbox-comfyui-node
- 安装依赖(在 ComfyUI 的 Python 环境里):
pip install -r ComfyUI/custom_nodes/xt-matte-toolbox-comfyui-node/requirements.txt
- 指定你的核心项目根目录(必须能看到
src/models/loader.py):
Windows PowerShell:
$env:XT_MATTE_PROJECT_ROOT="E:\抠图工具箱\小T抠图工具箱5.1.0"
python main.py
Linux/macOS:
export XT_MATTE_PROJECT_ROOT=/path/to/your/project
python main.py
关键参数建议
model_name- 质量优先:
Matting/Portrait - 速度优先:
General-Lite
- 质量优先:
resolution- 建议从
1024起,显存不足可降到768/512
- 建议从
semi_transparent- 处理发丝/薄纱/玻璃等半透明边缘
defringe- 去白边,强度建议
0.5~0.8
- 去白边,强度建议
roi_mask- 做局部抠图、减少误抠
模型加载与目录
节点会沿用你原项目的模型逻辑:
- 先找本地
models_local - 没有则尝试从 HuggingFace 下载
默认模型目录基于:
XT_MATTE_BASE_DIR(节点会自动设为项目根目录)- 结果通常是:
<XT_MATTE_BASE_DIR>/models_local
常见问题
-
节点不显示 检查是否放在
ComfyUI/custom_nodes/xt-matte-toolbox-comfyui-node,并重启 ComfyUI。 -
报
Project root not found说明没找到你的src/,请设置XT_MATTE_PROJECT_ROOT。 -
模型下载失败 检查网络、
transformers/huggingface-hub依赖、或手动放置模型到models_local/<模型目录>/。 -
OOM 显存不足 降低
resolution,换General-Lite,或降低批量。
二次开发入口
核心封装文件:
nodes.py
推荐开发顺序:
- 先改你主项目里的核心逻辑(
src/processors/image_processor.py) - 再映射到
nodes.py的INPUT_TYPES和matte()参数
这样桌面版和 ComfyUI 版逻辑可以保持一致,维护成本最低。
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.