ComfyUI Node

RandomLora

A roulette wheel for your LoRA collection

By TeaCrab·Created 3 years ago·Updated 5 months ago· 5
RandomLora
  • model
  • clip
  • MODEL
  • CLIP
  • RESULT
pattern
every7
pausefalse
skipfalse
seed0
strength_model1.00
strength_clip1.00

If you've got a folder of LoRAs you've never properly tested, RandomLora is the lazy way to sample them: it applies a random matching LoRA, keeps using it for N generations, then rolls again. Fire up a batch, walk away, come back to a contact sheet of what each LoRA actually does to your base model. It's a discovery tool wearing a loader's clothes.

It's one of ten nodes in the small ComfyUI-TeaNodes pack by TeaCrab, MIT, and it lives in the loaders category alongside its sibling RandomModel.

How it works

On load, the node scans your LoRA folder, filters it with a regex pattern, and picks one. A counter ticks up with every generation, and only when it hits a multiple of every does it roll a new LoRA. That cadence is the whole design: you're not re-rolling per image, you're giving each LoRA a fair little run. The state is dumped into the RESULT STRING output - current file, loop position, how many times each LoRA has been used, and which ones are still waiting in the pool - which you can read with any text-display node (Show Text, Preview Text) wired to the terminal.

There's a wrinkle in the code worth knowing: a seed input exists in the schema, but the implementation never actually consumes it - the pick is driven by Python's global random module, not your seed. So treat that input as decorative. If you want reproducibility, this node isn't the place to find it.

The inputs that matter

  • model / clip - the diffusion and CLIP models the LoRA applies to.
  • pattern - the regex filter over file names in models/loras. Empty pattern = everything.
  • every - generations before re-rolling (default 7, 1–99). The one you'll tune.
  • pause - freeze the current LoRA and stop the counter. Keep going forever on what you've got.
  • skip - force a re-roll right now, without resetting the loop count.
  • strength_model / strength_clip - standard LoRA strengths, both can go negative. Set both to 0 and the node passes the model through untouched.

Outputs: MODEL, CLIP (go to your sampler), and RESULT (the state string).

Where it bites

Three real gotchas. First, the pool is built from a hardcoded relative path (ComfyUI\models\loras - Windows-style backslashes). On a standard Windows install launched from the ComfyUI root it just works; on Linux/macOS or if you launch ComfyUI from elsewhere, the walk can come back empty and you'll see a "No Loras Found" warning (the author's fallback is supposed to pick from everything, but it can't pick from nothing - if your folder isn't found, check the console and make sure the path resolves). Second, loaded LoRAs are cached in RAM so the next visit doesn't hit the disk - which is great, until a long batch has been through dozens of LoRAs and you start eyeing your memory usage. Third, the README's "if the regex is wrong, it just picks from all" fallback is real, so a bad pattern won't kill you - it'll just be noisier than you wanted.

Installing it

ComfyUI Manager → search ComfyUI-TeaNodes, or:

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

restart ComfyUI. No model downloads; the pack's only declared dependency is the author's regex_spm helper (the regex support is why it's there).

It's a niche tool - you mostly want it for testing collections or adding variation to a batch. But for "I have 40 LoRAs and no idea which ones are good," it beats manually swapping a loader forty times.

Categoryloaders

Inputs (9)

NameTypeDefaultDescription
modelMODELThe diffusion model the LoRA will be applied to.
clipCLIPThe CLIP model the LoRA will be applied to.
patternSTRINGRegular Expression
everyINT71–99Change only takes effect every N generations.
pauseBOOLEANfalsePause the randomization and counting, keep generating with current lora.
skipBOOLEANfalseSkip curent model.
seedINT00–18446744073709550000
strength_modelFLOAT1.00-100–100How strongly to modify the diffusion model. This value can be negative.
strength_clipFLOAT1.00-100–100How strongly to modify the CLIP model. This value can be negative.

Outputs (3)

NameTypeDescription
MODELMODELThe modified diffusion model.
CLIPCLIPThe modified CLIP model.
RESULTSTRINGList of lora names that matches the pattern.