ComfyUI Node

ModelNames

Stop typing checkpoint paths by hand (and the filename rule that bites)

By lany42·Created 23 days ago·Updated a day ago· 1
ModelNames
    • MODEL_NAMES
    ◄models►
    ◄loras►

    ModelNames doesn't load a model. It doesn't even touch one. It's a picker that writes down which checkpoints and LoRAs you used, as a string, so that ImageSaverMini can hash them into your image metadata. The node's own description is one line long: "Select models and LoRAs for ImageSaverMini."

    Which tells you the real problem it solves. A metadata-friendly saver needs a comma-separated list of model paths relative to ComfyUI's models directory. Typing that by hand is miserable and one typo away from metadata that quietly points at nothing - or worse, at the wrong file. So this node lists what's actually on disk and lets you multi-select it.

    Inputs and output

    Two required COMBO inputs, and they're ordered selections, not sets:

    • models - every checkpoint and diffusion model found under ComfyUI's models directory. Tooltip: "Select checkpoints and diffusion models in output order. The first selection is the primary model."
    • loras - the LoRA folder, same idea. "They follow the models."

    One output: MODEL_NAMES, a STRING of comma-separated paths relative to the models directory.

    That ordering is the whole reason it's a list and not a checkbox grid. The first entry is the primary model - it's the one that becomes Model: and Model hash: in the metadata. Everything after it (including all the LoRAs) becomes part of the Hashes: block. Get the order wrong and your image will hash-match the wrong resource, or the right one will be in the pile rather than up front.

    The options aren't bare filenames, either. They're paths including the folder category, like checkpoints/shared.safetensors or loras/styles/ink.safetensors, built from the real filesystem and refreshed each time the node is defined - so a model you downloaded five minutes ago shows up after a refresh or restart rather than requiring a ComfyUI reload of the whole graph. Files living outside the models directory are skipped, because a path that can't be expressed relative to it can't be represented in the metadata contract.

    The trap: your filenames

    Here's where people get bitten, and it's worth reading before you wire anything. The saver's model-reference rules are strict, and ModelNames enforces them on selection: filenames may contain only ASCII letters, digits, underscores, hyphens and periods. No spaces. No parentheses. No non-ASCII characters. No colons or quotes. No empty components, no . or .., no absolute paths, no Windows drive letters or UNC prefixes. Select something that violates that and the node raises ImageSaverMini cannot represent models filename ... - the whole run stops.

    And yes, that includes the two names that are extremely common in a real models folder: juggernautXL_v9 (1).safetensors and 模型_v2.safetensors. Rename them (or make a symlink with a clean name) and you're fine. A second, sneakier version of the same rule: two files with the same filename in different folders can't both be in one list - they'd both hash into the same key, so the node rejects the duplicate rather than guessing.

    How to use it

    MODEL_NAMES → ImageSaverMini's models input. That's the whole wiring, and it's optional; you can type the string yourself if your memory for paths is better than mine. Worth knowing: the value that arrives is exactly the string the saver expects, so if you'd rather build it programmatically (an API call, a dynamic loader), you can format the same thing by hand - checkpoints/foo.safetensors,loras/bar.safetensors - and skip this node entirely.

    The other half of the picture: why the saver wants hashes at all. Because hosts match resources by hash. CivitAI reads the model hash out of your PNG's metadata and compares it against the models uploaded there to auto-link the checkpoint; one user's summary of the whole mechanism is about as clear as it gets - "The checkpoint is hashed and that is added into the metadata. When Civitai reads the metadata of your image for the resources used, it compares the hash against the models uploaded to Civitai" (1h9asvo > comment). If the resource isn't on the host, no amount of clean metadata will link it.

    Install

    cd /path/to/ComfyUI/custom_nodes
    git clone https://github.com/lany42/comfyui-lany-nodes.git
    # restart ComfyUI
    

    Manager users: search comfyui-lany-nodes ("ComfyUI Lany Nodes"). Nothing to download, runtime deps are numpy and Pillow. Needs Python 3.13+ and a ComfyUI with the V3 node API - on an older install the pack registers nothing at all, and you'll wonder where the node went.

    CategoryLany Nodes

    Inputs (2)

    NameTypeDefaultDescription
    modelsCOMBOSelect checkpoints and diffusion models in output order. The first selection is the primary model.
    lorasCOMBOSelect LoRAs in output order. They follow the models.

    Outputs (1)

    NameTypeDescription
    MODEL_NAMESSTRINGComma-separated paths relative to ComfyUI's models directory.