Nodes/tri3d-comfyui-nodes/Run AEMatter inference v5.1.0
ComfyUI Node

Run AEMatter inference v5.1.0

Matting with a trimap, for hair and edges that refuse to be cut

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Run AEMatter inference v5.1.0
  • image
  • trimap
  • AEMatter_Model
  • MASK

Background removal has a hard ceiling: binary segmentation has to call every pixel foreground or background, which is structurally wrong for flyaway hair, glass, or anything semi-transparent. Matting is the upgrade - it predicts fractional alpha instead of a hard mask, so hair keeps its soft edges. AEMatter is a matting model, and this node is its inference half.

The honest framing: this is a niche, old-ish node even by this pack's standards, and it needs a trimap (a mask marking definite foreground, definite background, and unknown zones) plus a GPU, plus an auto-downloaded checkpoint. It's not "click and remove the background" - it's for when you have a good mask already and need the edges done properly.

How it works

The model is AEM (an attention-based matting network) with weights pulled from a Human-Parsing checkpoint repo on Hugging Face (AEM_RWA.ckpt, downloaded on first run into models/AEMatter/). It takes your image and a trimap, and for each frame in the batch it predicts an alpha matte as a MASK.

The node is one half of a pair. First you load the model with the pack's tri3d-load_AEMatter_Model node (it has no inputs, downloads the checkpoint if missing, and loads it onto CUDA), then you wire that into this node's AEMatter_Model input.

The inputs that matter

  • image (IMAGE) - the subject.
  • trimap (MASK) - the crucial one. A tri-level mask: white = definite foreground, black = definite background, grey (intermediate) = the unknown edge zone the model gets to figure out. If you feed a plain binary mask instead of a real trimap, you're telling the model "there's no unknown region," which defeats the point - but it still runs.
  • AEMatter_Model - from the pack's loader node.

Output: a single MASK with the fractional alpha - softer edges than any binary cutout.

Installing it

Same pack, one install:

cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
cd tri3d-comfyui-nodes
pip install -r requirements.txt

Restart, and note this node lands in its own AEMatter category, not TRI3D. The checkpoint (~hundreds of MB) downloads automatically on first load into ComfyUI/models/AEMatter/.

Where people get burned

  • It requires CUDA, hard - the loader does model.cuda() unconditionally. CPU-only ComfyUI will crash on load, not gracefully.
  • The trimap gap - most people feed this a binary mask, get barely-better-than-segmentation results, and conclude it's bad. The whole value proposition is the grey unknown zone. Dilate your existing mask by a few pixels to build the unknown band and it behaves like a matting model should.
  • First-run download - the wget pull from Hugging Face can silently stall on flaky connections; if the node hangs on first use, check models/AEMatter/ for a partial file.

If you just want a quick cutout, don't start here - a BiRefNet or rembg node is one click. Reach for AEMatter when you've got a mask you trust and the edges matter more than the effort.

CategoryAEMatter

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
trimapMASK
AEMatter_ModelAEMatter_Model

Outputs (1)

NameTypeDescription
MASKMASK