MatAnyone2
One mask in, a whole video's alpha out
- src_video
- foreground_mask
- foreground_MASK
- solid_color
- matte
- green_screen
If you want to cut a person out of a video and keep the edges moving with the footage, this is the node you were looking for. MatAnyone2 is the newer, improved model in FuouM's pack, and it does something the per-image background removers can't: it takes a single mask you drew on one frame and propagates it through the whole clip, producing per-frame alpha that stays temporally consistent instead of shimmering like a frame-by-frame cutout. That distinction - matting with memory vs. re-segmenting every frame - is the whole point.
The model underneath is pq-yang's MatAnyone 2, "Scaling Video Matting via a Learned Quality Evaluator" (CVPR 2026), the sequel to the original MatAnyone (arXiv 2501.14677) whose weights made the rounds in early 2025. The first one earned genuinely good community reviews: people who tested it against SAM2 pointed out that SAM2's output is a hard matte that can't refine hair edges, while MatAnyone actually handles them. This node wraps the better version of that.
How it works
Consistent memory propagation. You feed it a video (an IMAGE batch) plus one annotated frame. There's a warmup phase - n_warmup iterations, default 10 - where the model turns your rough mask into its own first-frame alpha prediction. The README is upfront that "your input mask won't actually be in the final matte"; it's a seed, not the result. From there the alpha propagates through the clip while a rolling working memory of recent frames keeps it from drifting.
The inputs that matter
src_video- your clip as an IMAGE batch, typically from a Video Helper Suite Load Video node.foreground_mask(IMAGE) orforeground_MASK(MASK) - the annotated frame. The IMAGE version auto-converts a black/white image to a mask; the MASK version is more direct. Feed at least one.mask_frame- which frame that mask belongs to: 0 for first frame, or the last/middle index for backward or two-pass propagation.n_warmup- warmup iterations before propagation.r_erode/r_dilate- V2-only additions: morphological cleanup applied to your mask before it seeds the model. Bump them from 0 if your hand-drawn mask is noisy.- The memory trio:
max_internal_size(-1 = full res; try 480 or 360 to save VRAM),max_mem_frames(how many frames stay in high-res working memory, default 5),use_long_term(compresses older frames into long-term prototype memory - flip it on for long videos).
Outputs are matte (the alpha, as a grayscale-looking RGB batch - the channel is repeated three times) and green_screen (foreground composited over a solid color). Feed either into a VHS Video Combine to save it.
Install
Install is genuinely light. Grab it through ComfyUI Manager by searching "ComfyUI-MatAnyone", or:
cd ComfyUI/custom_nodes
git clone https://github.com/FuouM/ComfyUI-MatAnyone
then restart. The pack depends on only torch and omegaconf - the model code is vendored in the repo - so no dependency hell here.
The one thing you must do by hand is the model file:
# matanyone2.pth from https://github.com/pq-yang/MatAnyone2
# → ComfyUI/custom_nodes/ComfyUI-MatAnyone/checkpoint/matanyone2.pth
Miss this and the node raises FileNotFoundError the moment it loads.
Where people get burned
The quality of the mask you draw on that one frame is everything - the model propagates it, so garbage in means garbage over the whole clip. Don't hand-rotoscope if you can avoid it; generate the first-frame mask with BiRefNet or SAM and feed that in. If it OOMs on a long or high-res clip, drop max_internal_size to 480 (or 360) before blaming the node, and turn on use_long_term for anything past a few hundred frames. Also worth knowing: the green_screen output stays empty unless you actually wire solid_color in - the pack's example workflow uses the bundled SolidColorBatched node (default green) for exactly that. And both this node and the original reload the checkpoint from disk on every run, so expect a pause before the progress bar fills - that's normal, not a hang.
If you're torn between this and the older MatAnyone node in the same pack, don't be. Same inputs, same outputs, and this is the model the README now leads with.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| src_video | IMAGE | — | |
| mask_frame | INT | 0 | — |
| n_warmup | INT | 10 | — |
| foreground_maskopt | IMAGE | — | |
| foreground_MASKopt | MASK | — | |
| solid_coloropt | IMAGE | — | |
| r_erodeopt | INT | 0 | — |
| r_dilateopt | INT | 0 | — |
| max_internal_sizeopt | INT | -1 | — |
| max_mem_framesopt | INT | 5 | — |
| use_long_termopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| matte | IMAGE | — |
| green_screen | IMAGE | — |