Nodes/MatAnyone2 Video Matting/MatAnyone2 Model Loader
ComfyUI Node

MatAnyone2 Model Loader

The MatAnyone2 Model Loader

By dreamrec·Created 6 months ago·Updated 6 months ago· 3
MatAnyone2 Model Loader
    • matanyone_model
    model_nameMatAnyone 2
    checkpoint_path
    deviceauto

    Every ComfyUI pipeline has a boring-looking node at the top that quietly decides how good everything below it can be. For the MatAnyone2 Video Matting pack, that's this one. MatAnyoneModelLoader loads the video-matting checkpoint - the model that actually propagates your first-frame mask through the whole clip - and hands it to MatAnyone2 Matte as a MATANYONE_MODEL.

    The interesting bit is that it loads two generations of the model. The model_name dropdown has "MatAnyone 2" (default) and "MatAnyone". MatAnyone was the February 2025 release that got the community excited because it handled hair and semi-transparent edges that SAM2's hard mattes couldn't, and MatAnyone2 is the 2026 follow-up. Just leave it on "MatAnyone 2" unless you have a specific reason to test the original - you'd have to go out of your way to want the older weights.

    How it works

    The loader is thin on purpose, but there's real machinery behind it:

    • checkpoint_path left blank triggers an auto-download to ComfyUI/models/matanyone/ - the MatAnyone2 checkpoint (matanyone2.pth) comes from the pq-yang/MatAnyone2 GitHub releases, and MatAnyone's from pq-yang/MatAnyone. First run needs internet and a little patience.
    • If you do pass a path (say you keep checkpoints elsewhere), it validates the file exists and raises a clear error if it doesn't. The README explicitly suggests this for people who already have the weights.
    • The model is built from the vendored MatAnyone2 snapshot (the pack pins known-good upstream source in vendor/), loads via hydra config composition with single_object=True, and then - here's the part you'll feel - it's cached in memory keyed by (model_name, checkpoint_path, device). Queue the workflow twice and the second run skips the load entirely.
    • device defaults to auto, which asks ComfyUI's model_management for the right device and falls back to cuda → mps → cpu in that order.

    Inputs and outputs

    Three inputs, one output. model_name (the enum above), checkpoint_path (leave empty unless you manage weights manually), and device (you basically never touch this on auto). Output: matanyone_model - the only thing you can wire it into is the MatAnyone Matte node.

    Installing it

    This node has no install story of its own - it's the pack. ComfyUI Manager: search "MatAnyone2". Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/dreamrec/MatAnyone2_ComfyUI.git
    cd MatAnyone2_ComfyUI
    python -m pip install -r requirements.txt
    python install.py
    

    Restart. Requirements are light (hydra, huggingface_hub, opencv-headless, etc.), and install.py just validates the vendored snapshots and copies the demo clip into ComfyUI/input/.

    Where people get burned

    • "It's stuck downloading" - the checkpoint is a couple of GB from GitHub releases; that's normal on first load. Give it a minute rather than killing it.
    • "Checkpoint not found" - you typed a path, and the file isn't there. The node told you; the error is a FileNotFoundError with the exact path. Either fix the path or clear it and let auto-download work.
    • VRAM - the loader isn't the hog; the Matte node is. But the model sits in RAM cache after loading, so if you're juggling memory, know that's where a chunk went. Nothing you need to "fix" - just awareness.

    Honestly, you'll set model_name, ignore everything else, and forget it exists. That's the sign of a good loader.

    CategoryMatAnyone2

    Inputs (3)

    NameTypeDefaultDescription
    model_nameCOMBOMatAnyone 22 options: MatAnyone 2, MatAnyone
    checkpoint_pathSTRING
    deviceCOMBOauto4 options: auto, cuda, mps, cpu

    Outputs (1)

    NameTypeDescription
    matanyone_modelMATANYONE_MODEL