ComfyUI Node

SAM Words

SAM 3.1 can find anything you can name. This node makes sure you actually named it.

By AInVFX·Created about a month ago·Updated a day ago· 223
SAM Words
    • words
    ◄text—►
    ◄kindthing►

    A text filter, and nothing more

    The name is a little misleading in the best way: SAM Words doesn't run SAM, doesn't load a model, doesn't touch your VRAM. It's a string cleaner. Two strings in, one out, no CUDA involved.

    What it fixes is a real seam in the pipeline. SAM 3's headline feature - the one that folded the old GroundingDINO-plus-SAM two-model ritual into a single loadable checkpoint - is open-vocabulary text prompting: describe an object as a short noun phrase and it returns masks for every matching instance. Short is doing a lot of work in that sentence. Meanwhile the thing you actually have upstream is a prompt upsampler or a vision model writing a full descriptive sentence about your image. Hand "a weathered floodlight pole standing at the edge of a wet road" to SAM 3.1's conditioning and you're asking it to match a phrase it has no concept for.

    SAM Words sits in that gap. It's one of sixteen nodes in Paint a plate, AInVFX's VFX tool that won comfy.org's Open Source Higgsfield contest in November 2026, where the matte for every Clean and Paint edit comes out of SAM 3.1 - so a mis-named object isn't a cosmetic bug, it's your edit vanishing from frame 40 onward.

    How it works

    It normalises the answer first: collapses whitespace, lowercases it, drops a trailing full stop. Then the kind decides which of two rules applies.

    With thing - the default, and what you want for the object being painted or removed - it cuts the sentence at the first structural word it finds: with, in, on, at, from, behind, outside, including, that, which, a comma, or a participle like standing, landing, rising, hanging, overlapping. So "bald eagle landing on the fence post" becomes "bald eagle". Everything after the object is a description of what it's doing or where it is, and none of it helps SAM find it.

    With kept it goes the other way: splits on commas, throws away entries of more than four words, discards none and any denial starting with no (a captioner's "no other people visible" is a negative, and a segmenter asked to find it will find something), drops entries containing visible, and returns the first survivor. That's the subject the plate must protect - the person, animal or vehicle whose pixels your edit must not touch.

    Output is words: one lowercase noun phrase, or an empty string. That's the whole node.

    The two fields

    • text - the prompt upsampler's answer. It's a forced input, so it comes off a wire, not a text box you type in. In the pack's graphs that wire is a TextGenerate call against the prompt-writing model with the first frame attached.
    • kind - thing for the edit's object, kept for the subject the plate keeps.

    And the output, words, goes into a CLIPTextEncode built on SAM 3.1's text encoder, which then feeds the text conditioning of the tracking node. If you're wiring this yourself: cleaner → encoder → conditioning input.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/AInVFX/ainvfx-paintaplate
    python -m pip install -r ainvfx-paintaplate/requirements.txt
    

    Manager users: search Paint a plate, install AInVFX Paint a plate, restart. The requirements are just OpenEXR and opencolorio - the 79 GB of weights are for the app, not for this node.

    To see it in anger you need SAM 3.1 itself (sam3.1_multiplex_fp16.safetensors, into models/checkpoints). The pack's own workflows are the fastest way to learn the wiring - it exports them from the app as runnable graphs.

    Where people get burned

    The cut is aggressive, and that's the feature. Name something as "the man on the bike" and you've asked SAM for a man. If the tracking is locking onto the wrong person, add the distinguishing word before the preposition - "cyclist in the red jacket" still cuts at in, so put the colour where it survives: "red-jacketed cyclist". Then re-track and look at frame one.

    kept can return nothing, silently. Every entry over four words, or the answer being "none", or a captioner that wrote "no other people visible" - all of those give you an empty string. An empty conditioning is not an error message, it's just SAM with nothing asked of it. If your matte behaviour changes for no visible reason after you swapped the prompt writer, check this node's output first.

    It can't rescue a bad caption. It's a lint pass, not a guesser. If the upsampler names the wrong object, SAM Words will hand SAM a perfectly clean name for the wrong object.

    Matte loss is often a naming problem. The pack's own docs say a paint's matte can lose the object on some frames when SAM 3.1 stops finding it, and the first suggested fix is another text prompt - meaning a shorter, denser noun phrase, before you go reseeding and repainting. This node is the cheap place to make that change.

    CategoryAInVFX/Paint a plate

    Inputs (2)

    NameTypeDefaultDescription
    textSTRINGThe prompt upsampler's answer.
    kindCOMBOthingthing: the edit's object. kept: the first person, animal or vehicle of the list.

    Outputs (1)

    NameTypeDescription
    wordsSTRING—