Nodes/Comfy_KepMatteAnything/MatteAnything_LoadDINO
ComfyUI Node

MatteAnything_LoadDINO

The text-prompted object finder that's lighter than it looks

By M1kep·Created 3 years ago·Updated 2 years ago· 11
MatteAnything_LoadDINO
    • DINO_MODEL
    model_name
    device_mode

    The SAM loader gets the spotlight, but half of what makes Matte Anything feel like magic is text. You type "the person on the left", and the pack knows where to cut. That trick comes from GroundingDINO, and MatteAnything_LoadDINO is the node that pulls its weights into the graph. It's the quiet workhorse of the pair: no flashy output, but nothing downstream runs without it.

    What it does

    GroundingDINO is a text-prompted object detector - the "DINO" half of the classic GroundingDINO + SAM combo that's been doing targeted selection in this community since 2023. You give it a caption, it returns bounding boxes around whatever matches. In this pack those boxes are what point SAM at the right part of the image, so you never have to draw a mask or click a point by hand.

    The loader reads a checkpoint from ComfyUI/models/dino/ and hands it to the groundingdino-py library as a DINO_MODEL. It's the Swin-T ("tiny") variant, which is the lightweight end of GroundingDINO - that's a feature, not a downgrade. Detection is fast even on modest hardware, and it's the model that'll let you batch images through the same caption without touching anything.

    One honest quirk

    The node takes a device_mode input (AUTO, Prefer GPU, CPU), same as the other loaders in this pack. It's decorative here. The code loads the model with device="cpu" unconditionally, ignoring whatever you picked. It works because GroundingDINO-SwinT is small enough that running it on CPU costs you very little - but if you were hoping for a per-node GPU toggle, this isn't the place to find it.

    Inputs and outputs

    • model_name - dropdown of checkpoints in models/dino/. The one you want is groundingdino_swint_ogc.pth (~700MB) from the official GroundingDINO release.
    • device_mode - exists, ignored, see above.
    • Output: one DINO_MODEL, which feeds MatteAnything_DinoBoxes.

    Installing this pack

    ComfyUI Manager, search Comfy_KepMatteAnything, install - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/M1kep/Comfy_KepMatteAnything
    

    then restart ComfyUI. Dependencies are shared across the pack: segment-anything, detectron2, and groundingdino-py. Detectron2 is the rough one (native C++/CUDA build, Windows-hostile, Linux-fine); groundingdino-py on PyPI is what makes this node work.

    Drop the weights in:

    mkdir -p ComfyUI/models/dino
    # groundingdino_swint_ogc.pth into ComfyUI/models/dino/
    

    Gotchas

    • Wrong-file error if you grab the wrong DINO weights. The loader expects a checkpoint the groundingdino-py library can build from. If you grabbed a different GroundingDINO release, expect a load failure that reads like a Python stack trace rather than a friendly message.
    • The README won't mention any of this. The pack's own README is a stub; the bundled academic README documents the original Gradio app's ./pretrained/ layout, which doesn't match ComfyUI's models/ folders. Follow the models/dino/ path above.

    Honest take: GroundingDINO's text-prompting is the reason this pack feels like a product instead of a research demo - and it's also why the pack needs three models and a detectron2 install just to stand up. If that price is too steep and you only need simple foreground removal, you don't need any of this. If you need specific objects picked by words, this is the node that makes it possible.

    CategoryMatte Anything

    Inputs (2)

    NameTypeDefaultDescription
    model_nameCOMBO0 options:
    device_modeCOMBO3 options: AUTO, Prefer GPU, CPU

    Outputs (1)

    NameTypeDescription
    DINO_MODELDINO_MODEL