ComfyUI Node

XT Matte Cutout

The node that won't run without its desktop app

By XIAOTsune·Created 6 months ago·Updated 6 months ago· 0
XT Matte Cutout
  • image
  • roi_mask
  • foreground
  • alpha_mask
  • mask_preview
model_name
resolution1024
semi_transparentfalse
semi_strength0.50
defringefalse
defringe_strength0.70
roi_crop_beforetrue
roi_pad_px16

XT Matte Cutout is the ComfyUI face of a Chinese Windows desktop matting tool - 小T抠图工具箱 ("XT Matte Toolbox") - and it is honest about it in a way most ported nodes aren't. There's exactly one node here, XTMatteCutout under XT/Matting, and it does one thing: feed it an image, get back a foreground, an alpha mask, and a mask preview. Hair, fur, glass, mesh - the hard cases where rembg's old u2net visibly falls apart.

Here's the catch, and it's the first thing you need to know: this node is not self-contained. It's a thin wrapper around the matting engine living in the author's separate desktop project. Clone it, install its deps, and it will refuse to load with Project root not found unless an environment variable points it at a copy of that project. If you don't own the XT Matte Toolbox desktop app, this pack is a dead end before you even open the node menu.

How it actually works

The mechanism is unusual and worth understanding, because it's why the install is fiddly. On import, the pack runs a bootstrap that hunts for a directory containing src/models/loader.py - first checking the XT_MATTE_PROJECT_ROOT env var, then walking its own parent directories. Once found, it sets XT_MATTE_BASE_DIR to that root, sticks it on sys.path, and imports two things live from the parent project: apply_background_replacement from src/processors/image_processor.py, and the model list from src/config.py's USAGE_TO_WEIGHTS_FILE.

In other words, the entire intelligence - model loading, resolution handling, edge refinement - lives in the desktop app's src/, and the ComfyUI node is a 200-line adapter. The ten model choices (General, General-Lite, General-Lite-2K, Matting, Portrait, DIS, HRSOD, COD, DIS-TR_TEs, General-legacy) are just keys into that parent project's config, and they'll be replaced by whatever that file defines. If you've read the background-removal debates, those names should look familiar - DIS, HRSOD and COD are the benchmark families BiRefNet also publishes weights for, and the Matting/Portrait entries are the trimap-free matting variants that predict fractional alpha instead of a hard mask.

The inputs that matter

Most of the schema is defaults you can ignore. The three you'll actually touch:

  • model_name - README's advice is sound: Matting/Portrait for quality, General-Lite when you want speed or your VRAM is crying.
  • resolution - default 1024, range 256–2048 in steps of 64. Start at 1024; drop to 768/512 if you OOM.
  • semi_transparent (with semi_strength, default 0.5) - for hair, veils, glass. defringe + defringe_strength (0.7) kills the white halo on composited edges.

The optional roi_mask is the interesting one: hand it a mask and the node restricts matting to that region, with roi_crop_before and roi_pad_px (16) controlling whether it crops first. Great for local fixes when the model mis-picks on a busy background. Outputs are foreground (IMAGE), alpha_mask (MASK), and mask_preview (IMAGE) - wire the alpha into a composite or Save Image node.

Installing it (the real way)

cd ComfyUI/custom_nodes
git clone https://github.com/XIAOTsune/xt-matte-toolbox-comfyui-node
cd xt-matte-toolbox-comfyui-node
pip install -r requirements.txt

Then restart ComfyUI - but before that, the step the README can't make generic for you:

export XT_MATTE_PROJECT_ROOT=/path/to/your/xt-matte-project

That path must contain src/models/loader.py. The README's example (E:\抠图工具箱\小T抠图工具箱5.1.0) is the author's own project root. Models load from <project_root>/models_local first, and fall back to downloading from HuggingFace. The requirements.txt is heavy for one cutout node - transformers, accelerate, timm, kornia, scipy, scikit-image, plus numpy<2 - so expect a chunky install and don't be surprised if it fights your existing environment.

Common issues

  • Project root not found - the bootstrap failed. Set XT_MATTE_PROJECT_ROOT (or make sure the pack sits inside a tree that has the parent project's src/).
  • Node missing from the menu - check it's in custom_nodes/xt-matte-toolbox-comfyui-node and you restarted.
  • Model download errors - network/transformers/huggingface-hub trouble; the README suggests manually dropping weights into models_local/<model_dir>/.
  • OOM - lower resolution, switch to General-Lite, cut your batch.

The honest verdict

Background removal is the most commoditized operation in this ecosystem - BiRefNet shipped in ComfyUI core in May 2026, and any of the RMBG-style packs will cut a subject out without a desktop app dependency. This node only earns its keep if you already run XT Matte Toolbox's desktop version and want pixel-identical results inside ComfyUI. As a bridge for an existing user, it's tidy. As a standalone cutout tool for a beginner, you're installing someone else's app by proxy - go use core BiRefNet instead, and revisit this pack if the author ever ships the models and src/ in the repo itself.

CategoryXT/Matting

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
model_nameCOMBO10 options: General, General-Lite, General-Lite-2K, Matting, Portrait, DIS, +4
resolutionINT1024256–2048
semi_transparentBOOLEANfalse
semi_strengthFLOAT0.500–1
defringeBOOLEANfalse
defringe_strengthFLOAT0.700–1
roi_crop_beforeBOOLEANtrue
roi_pad_pxINT160–256
roi_maskoptMASK

Outputs (3)

NameTypeDescription
foregroundIMAGE
alpha_maskMASK
mask_previewIMAGE