Nodes/ComfyUI-ImageWithMetadata/Random Diffusion Model Loader with Names
ComfyUI Node

Random Diffusion Model Loader with Names

Batch-test every Flux, SD3, or Anima model in a folder without rebuilding the workflow

By shin131002·Created 7 months ago·Updated 4 days ago· 6
Random Diffusion Model Loader with Names
    • model
    • diffusion_model_name
    mode
    seed0
    path
    sub_folders
    pattern*
    labelBatch 001
    index0
    weight_dtype

    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 random with the seed input and does random.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, honoring sub_folders (recursive) and pattern (a filename glob - *29B* matches only your partial finetunes, * grabs everything). Only .safetensors, .sft, and .pt count.

    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) or random (seed-based).
    • path - the folder to scan. Leave it empty to use ComfyUI's default diffusion_models folder.
    • 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 path falls back silently to the default diffusion_models folder (with a console warning). If it's "loading" models you don't expect, check the console.
    • Files must resolve under a diffusion_models root 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 found error. Double-check pattern before blaming the pack.
    • fp8 is the easy VRAM win. If you're on 12–24GB, fp8_e4m3fn halves the footprint of a Flux-class model with near-invisible quality loss - the community default for good reason.
    Categoryloaders

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBO2 options: single, random
    seedINT00–18446744073709550000
    pathSTRING
    sub_foldersCOMBO2 options: false, true
    patternSTRING*
    labelSTRINGBatch 001
    indexINT00–150000
    weight_dtypeCOMBO4 options: default, fp8_e4m3fn, fp8_e4m3fn_fast, fp8_e5m2

    Outputs (2)

    NameTypeDescription
    modelMODEL
    diffusion_model_nameSTRING