Nodes/MatAnyone2 Video Matting/MatAnyone2 Preview Masks
ComfyUI Node

MatAnyone2 Preview Masks

See Your Masks Before You Commit Them

By dreamrec·Created 6 months ago·Updated 6 months ago· 3
MatAnyone2 Preview Masks
  • image
  • mask_a
  • mask_b
  • mask_c
  • mask_d
  • preview
opacity0.65

A mask is just a tensor of numbers until you see it on top of the actual frame. MatAnyonePreviewMasks draws up to four mask overlays onto your source image so you can actually look at what SAM decided before you send it into the Matte node and burn GPU minutes on a bad cut.

The README frames this pack around "create and compare multiple mask targets before committing," and this node is the compare part. The editor gives you live previews while you click; the scripted path needs this node to fill the same role - an eyeball check between "SAM refined this" and "MatAnyone propagated this."

How it works

Inputs: image (the source frame), mask_a (required), and optional mask_b, mask_c, mask_d, plus opacity (default 0.65). Each mask is resized to the image dimensions and drawn in a fixed color - green, blue, orange, red in that order, if you're curious which mask is which - composited at the opacity you set. One output: preview (an IMAGE you can wire to any Preview node or Save Image).

That color coding is the genuinely useful part. Give it two masks from different SAM targets and you immediately see where they agree, where they disagree, and whether the union is going to include something you didn't intend. It's a two-second check that prevents a five-minute matte run on a wrong mask.

Where it sits

In the extended demo it runs in parallel with the mask pipeline - same masks, different purpose - so you can inspect without disturbing the data flow. It pairs naturally with Merge Masks: preview each input, merge, preview the merge, and only then hand the result to the Matte node.

Install & the gotcha

It's in the MatAnyone2 Video Matting pack: ComfyUI Manager search "MatAnyone2", or clone + pip install -r requirements.txt + python install.py + restart.

One thing to know: this node is a viewer, not a validator. It shows you the mask on the frame, but it won't warn you that two masks are from different frames or different resolutions - it just stretches everything onto image and draws it. If you're debugging a bad final matte, the first question should be whether the masks you're previewing even belong to this frame. The node is a mirror, not a conscience. Also, opacity is global across all four masks - you can't dim one and brighten another. Fine for inspection, not a compositing tool; don't expect per-mask control.

CategoryMatAnyone2/SAM

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
mask_aMASK
opacityFLOAT0.650–1
mask_boptMASK
mask_coptMASK
mask_doptMASK

Outputs (1)

NameTypeDescription
previewIMAGE