ComfyUI Node

RandomModel

Random checkpoint every N runs — bring RAM

By TeaCrab·Created 3 years ago·Updated 5 months ago· 5
RandomModel
    • MODEL
    • CLIP
    • VAE
    • RESULT
    pattern
    every7
    pausefalse
    skipfalse
    seed0

    RandomModel is RandomLora's bigger, hungrier cousin. Instead of cycling through LoRAs, it cycles through whole checkpoints in models/checkpoints: filter by regex, hold onto one for N generations, then roll the next. Where RandomLora is a discovery tool for a folder of LoRAs, this one is a discovery tool for your entire model collection - and it does exactly the same thing in the graph that you'd otherwise do by hand, reloading a loader every few runs.

    It's one of ten nodes in the small ComfyUI-TeaNodes pack by TeaCrab, MIT, in the loaders category.

    How it works

    Same machinery as RandomLora, pointed at a different folder. On load it walks models/checkpoints, filters by your regex pattern, and picks one. A loop counter decides when to re-roll: only when the run count hits a multiple of every (default 7) does it switch models. pause freezes the current model indefinitely, skip forces an immediate re-roll without resetting the count. The full working state - which model is loaded, how many times each has been used, what's still waiting in the pool - comes out the RESULT STRING output, to be read with Show Text or Preview Text.

    Unlike RandomLora, this node is a full loader: it emits MODEL, CLIP, and VAE, all three wired straight to your sampler. You don't need a checkpoint loader anywhere else in the graph - RandomModel is the loader.

    Two quirks from the code you should know before you trust it. The seed input exists but is never consumed - picks come from Python's global random module, so don't expect reproducibility. And if you zero out the strengths on RandomLora it passes through gracefully, but here there's no such escape hatch: this node always loads a full model.

    The inputs that matter

    • pattern - regex filter over checkpoint file names. Empty = every checkpoint you own.
    • every - generations per model (default 7, 1–99).
    • pause - hold the current model and stop counting.
    • skip - re-roll now.

    Outputs: MODEL, CLIP, VAE, and RESULT (the state string).

    The honest warning

    Checkpoints are loaded and then kept in RAM so a repeated model doesn't hit the disk again - and the README says flat out that this "can lead to maxing out the RAM usage." Where RandomLora's cache is a handful of small state dicts, this one is holding entire models. Run through ten SDXL-era checkpoints in one batch and your system memory gets serious. The author's position is that Python handles it, which is true until it isn't - if you batch long enough to cycle through most of your collection, watch the RAM meter and expect the OS to start swapping. Consider pairing it with a small every so a given session doesn't churn through everything you own.

    The path gotcha from RandomLora applies here too: the pool is walked from a hardcoded relative ComfyUI\models\checkpoints (backslashes and all). Windows, launched from the ComfyUI root, works. Linux/macOS or a different working directory can come up empty - if you see "No Models Found" in the console, that's the walk failing, not your regex.

    Installing it

    ComfyUI Manager → search ComfyUI-TeaNodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TeaCrab/ComfyUI-TeaNodes
    

    restart ComfyUI. No downloads; the pack's only declared dependency is the author's regex_spm helper.

    Bottom line: it's a fun, occasionally reckless way to A/B your model collection. Use it with an eye on RAM, and you'll learn which checkpoints you actually like - just don't leave a 200-model batch running unattended.

    Categoryloaders

    Inputs (5)

    NameTypeDefaultDescription
    patternSTRINGRegular Expression
    everyINT71–99Change only takes effect every N generations.
    pauseBOOLEANfalsePause the randomization and counting, keep generating with current model.
    skipBOOLEANfalseSkip curent model.
    seedINT00–18446744073709550000

    Outputs (4)

    NameTypeDescription
    MODELMODELThe model used for denoising latents.
    CLIPCLIPThe CLIP model used for encoding text prompts.
    VAEVAEThe VAE model used for encoding and decoding images to and from latent space.
    RESULTSTRINGList of model names that matches the pattern.