Nodes/Image with Metadata/Random Checkpoint Loader with Names
ComfyUI Node

Random Checkpoint Loader with Names

Rotate or Randomize Checkpoints Without Rewiring a Thing

By shin131002·Created 8 months ago·Updated 19 days ago· 6
Random Checkpoint Loader with Names
    • model
    • clip
    • vae
    • checkpoint_name
    • vae_name
    mode
    seed0
    path
    sub_folders
    pattern*
    labelBatch 001
    index0
    vae_name

    You want to run the same prompt through five checkpoints to compare them, or sweep a whole folder of models in one batch. The manual way: swap the checkpoint dropdown, note the name, generate, repeat, and pray you remember which image came from which model. Random Checkpoint Loader with Names automates exactly that - point it at a folder, pick sequential or seed-based random, and it loads the checkpoint and hands you its name as a string so your metadata stays honest.

    It's part of ComfyUI-ImageWithMetadata, the small MIT pack by shin131002 built around batch image load/save with metadata. Same install as its sibling node, same zero-dependency story, and the loader internals trace back to WAS Node Suite's proven BatchImageLoader pattern.

    How it works

    On every run it globs your chosen folder for checkpoint files (.safetensors, .ckpt, .pt), filters by a glob pattern, then loads through ComfyUI's own CheckpointLoaderSimple under the hood. Selection is where the two modes split:

    • single mode - index % number_of_checkpoints. Drive an Integer node (with control_before_generate: increment) into index and each run steps to the next model, wrapping around at the end of the list.
    • random mode - it seeds Python's random with your seed and picks one. Same seed, same model, every time. That determinism is the feature: a failed run is rerunnable.

    It also keeps a tiny JSON "counter DB" in ComfyUI's temp folder, keyed by label. Its only real job here is detecting when you've changed the path or pattern and resetting stale state - the actual selection comes from index or seed.

    The inputs that matter

    • mode - single (sequential, recommended) or random.
    • path - folder of checkpoints. Empty means all checkpoints folders - the README explicitly warns against it.
    • pattern - glob filter: * for everything, anime_*, *.safetensors.
    • sub_folders - false/true, recursive search into subfolders.
    • index - used in single mode; feed it from an incrementing Integer.
    • seed - model-selection seed in random mode.
    • label - namespace for this node's state; use a distinct label per folder/batch.
    • vae_name - "Baked VAE" (default) or an external VAE.

    Outputs: model, clip, vae plus checkpoint_name and vae_name as strings. Pipe those strings into the pack's Save Image with Metadata and every PNG records which checkpoint actually produced it.

    Installing it

    Search "ImageWithMetadata" in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/shin131002/ComfyUI-ImageWithMetadata.git
    

    Restart, done. No requirements.txt, no model downloads. Small personal project, MIT, quiet support policy - stable but don't expect rapid fixes.

    Where people get burned

    1. Empty path is BaseModel roulette. SD1.5, SDXL, and Illustrious checkpoints all live in ComfyUI's checkpoints folder, and loading a model from the wrong family mid-batch errors out or gives garbage. Set path to a folder holding one BaseModel family and keep the others out.
    2. pattern is glob, not regex. anime_* works; anime_.* doesn't.
    3. Same seed = same model. In random mode the seed picks the checkpoint, and if you also reuse the sampler's seed you can paint yourself into identical output on purpose. Give the loader its own seed when you want variety.
    4. index wraps silently. index 100 with 10 models loops back to model 0 - fine for a batch, confusing when you thought you were on model 10.
    5. "Model not found." Verify the path exists, sub_folders matches your layout, the pattern matches, and the folder is actually registered (external drives usually need extra_model_paths.yaml). A path outside the registered bases degrades to a basename lookup CheckpointLoaderSimple can't resolve.

    Worth it? If you A/B test models or run folder-wide batch generations, yes - it turns a tedious dropdown dance into one Integer node, with model names captured for free. If you only ever run one model, skip it; the plain Checkpoint Loader with Names gives you the same outputs with fewer knobs.

    Categoryloaders

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBO2 options: single, random
    seedINT00–18446744073709550000
    pathSTRING
    sub_foldersCOMBO2 options: false, true
    patternSTRING*
    labelSTRINGBatch 001
    indexINT00–150000
    vae_nameoptCOMBO1 options: Baked VAE

    Outputs (5)

    NameTypeDescription
    modelMODEL
    clipCLIP
    vaeVAE
    checkpoint_nameSTRING
    vae_nameSTRING