MatAnyone2 Model Loader
The MatAnyone2 loader that fetches its own weights (and you'll forget about it)
- matanyone2_model
This is the boring half of ComfyUI-MatAnyone2, and that's a compliment. Every ComfyUI workflow needs someone to haul the checkpoint into memory, and this node does it with exactly two inputs and one output - then gets out of the way. Its sibling MatAnyone2 Video Matting does the actual video matting; this one just makes sure the model is loaded, cached, and sitting on the right device. If you're trying to cut a person out of a video clip, you need it, but you'll spend almost no time thinking about it.
What it actually does
The node loads the MatAnyone2 checkpoint (matanyone2.pth) into VRAM and hands it to the matting node. Three details make it less trivial than it looks:
- Auto-download. With
auto_downloadon (it's on by default), the first time you run the workflow it fetches the.pthfrom the MatAnyone2 GitHub release intoComfyUI/models/matanyone2/and proceeds. No hunting for a HuggingFace link, no manual drop-into-folder. - In-process caching. The model is cached per (checkpoint path, device) with a lock around it, so the second run of your workflow doesn't re-initialize the network. The README warns the first load is slow; that's the cache being built.
- A decent error message. Turn
auto_downloadoff and the file's missing, and it raises aFileNotFoundErrorthat literally tells you to re-enable auto-download or drop the weights inComfyUI/models/matanyone2/. More packs could learn from this.
The inputs and output
Only two inputs exist, and you'll touch one of them:
model_name- an enum that currently only offersmatanyone2.pth. The dropdown scans yourmodels/matanyone2folder, so if you stash other checkpoints there they'll show up; for now there's exactly one model to choose.auto_download- a boolean, defaulttrue. Leave it on. The only reason to flip it is if you're offline and have already placed the weights yourself.
The output is a single matanyone2_model of the custom MATANYONE2_MODEL type. It wires straight into the matanyone2_model input of MatAnyone2 Video Matting. There's nothing else it plugs into - that's the whole graph edge.
Installing it
The pack is a standard custom node:
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/starsFriday/ComfyUI-MatAnyone2.git
cd ComfyUI-MatAnyone2
pip install -r requirements.txt
Then restart ComfyUI. ComfyUI Manager has it too - search "MatAnyone2" or "MatAnyone2 Video Matting" and install from there. The requirements list is real and a bit chunky: torch>=2.1, torchvision, opencv-python, imageio[ffmpeg], einops, hydra-core, omegaconf, safetensors, huggingface_hub. You already have most of these if ComfyUI runs; the node's own pip install -r requirements.txt will skip the ones that satisfy the version pins.
Where people trip up
The one genuine gotcha is the model folder. The checkpoint goes in ComfyUI/models/matanyone2/, not the checkpoints folder you're used to, and if you hand-place the weights, that's where they belong. Forget it and you'll get the FileNotFoundError above, not a silent failure.
The model is a first-frame-propagation matting network, so the loader itself can't "fail" at matting quality - but know that the loaded weights are the single-target pipeline (objects=[1]), i.e. one foreground subject per run. Fine for a person cutout; not a multi-object scene decomposer.
One aside worth keeping in your back pocket: MatAnyone2 is new (released March 2026), so the "cache is warm" behavior is the difference between a painful and a painless iteration loop. Let the first run finish, then iterate on your mask - subsequent runs will skip the model load entirely.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 1 options: matanyone2.pth | |
| auto_download | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| matanyone2_model | MATANYONE2_MODEL | — |