Random Diffusion Model Loader with Names
Batch-test every Flux, SD3, or Anima model in a folder without rebuilding the workflow
- model
- diffusion_model_name
The name is half the story. "Random Diffusion Model Loader with Names" is the sibling of the pack's checkpoint loader, but built for the architectures that don't ship as one tidy .safetensors checkpoint - Flux, SD3, Anima, and anything else that hands you the diffusion model as a standalone file. In ComfyUI that file lives in your diffusion_models folder and gets loaded by the built-in Load Diffusion Model (UNETLoader) node, not CheckpointLoaderSimple. This node wraps that loader and bolts on the batch machinery: point it at a folder, and it will grind through every model in it, one at a time, telling you which one made which image.
Why would you want that? Because "which fine-tune do I actually like" is a question nobody answers by hand. Manually swapping a UNET, re-running, and writing down the result is miserable. Wire an Integer node (set to increment) into this loader's index, group the two nodes, and let it walk your whole Anima folder while you go make tea. That's the pattern the pack's README recommends, and it's the honest reason anyone installs this pack at all.
How it works
Under the hood it's a thin wrapper around ComfyUI's own UNETLoader.load_unet(), so the file handling, Anima block-count detection, and weight_dtype casting behave exactly like the stock node. The selector does the work:
- single mode: picks
model_list[index % len(model_list)]. The modulo means it wraps instead of erroring - handy for loops, slightly weird if you expected a hard boundary. - random mode: seeds Python's
randomwith theseedinput and doesrandom.choice. Same seed, same model, every time. That reproducibility is the whole point if you're comparing outputs. - The model list is built with glob over
path, honoringsub_folders(recursive) andpattern(a filename glob -*29B*matches only your partial finetunes,*grabs everything). Only.safetensors,.sft, and.ptcount.
A counter database in ComfyUI's temp folder tracks position per label, and it auto-resets when the path/pattern change, so stale counters won't bite you mid-batch.
Inputs and outputs that matter
There are eight inputs but a beginner touches a handful:
- mode -
single(external index, recommended) orrandom(seed-based). - path - the folder to scan. Leave it empty to use ComfyUI's default
diffusion_modelsfolder. - pattern -
*for everything, or a partial-name filter. - index / seed - whichever matches your mode.
- weight_dtype -
default/fp8_e4m3fn/fp8_e4m3fn_fast/fp8_e5m2, identical to the built-in Load Diffusion Model node.
Outputs: model (MODEL) → KSampler, and diffusion_model_name (STRING) → the filename only, no subfolder path. That string is what makes this node worth installing: feed it into the pack's Save Image with Metadata with overlay_text on, and the model name gets burned into the pixels. Six hours later you can tell which image came from which model at a glance, no notes required.
Installing
ComfyUI Manager (search "Image with Metadata"), or:
cd ComfyUI/custom_nodes/
git clone https://github.com/shin131002/ComfyUI-ImageWithMetadata.git ImageWithMetadata
Then restart ComfyUI. That's it - no extra dependencies; it only uses ComfyUI's bundled numpy/torch/PIL.
Gotchas
- Empty or wrong
pathfalls back silently to the defaultdiffusion_modelsfolder (with a console warning). If it's "loading" models you don't expect, check the console. - Files must resolve under a
diffusion_modelsroot for the internal loader to find them. A model outside every configured base gets a bare filename and may fail to load. - It only outputs MODEL. For Flux, SD3, and Anima you still need the matching text encoder and VAE wired in separately - this node replaces one tile of the workflow, not the whole thing. Don't drop it into an SDXL-style graph.
- No matching files → the node raises a clear
No diffusion models founderror. Double-checkpatternbefore blaming the pack. - fp8 is the easy VRAM win. If you're on 12–24GB,
fp8_e4m3fnhalves the footprint of a Flux-class model with near-invisible quality loss - the community default for good reason.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 2 options: single, random | |
| seed | INT | 00–18446744073709550000 | — |
| path | STRING | — | |
| sub_folders | COMBO | 2 options: false, true | |
| pattern | STRING | * | — |
| label | STRING | Batch 001 | — |
| index | INT | 00–150000 | — |
| weight_dtype | COMBO | 4 options: default, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |
| diffusion_model_name | STRING | — |