Nodes/ComfyUI-SizeFromPresets/Random Empty Latent Image From Presets (SD1.5)
ComfyUI Node

Random Empty Latent Image From Presets (SD1.5)

Roll the dice on your SD1.5 canvas — one seed, five trained sizes

By nkchocoai·Created 3 years ago·Updated about a year ago· 13
Random Empty Latent Image From Presets (SD1.5)
    • latent
    • w
    • h
    batch_size1
    seed0

    Want a different canvas size every generation without touching a slider? That's the whole job of this node. It picks one of the five SD1.5 presets from the pack's sd15.csv at random, builds an empty latent at that size, and hands you the width and height too. Drop it where you'd normally put the core Empty Latent Image node and your queue produces a mix of squares, landscapes, and portraits - useful for exploring compositions, building image-grid datasets, or just letting the model pick a frame for you.

    It comes from nkchocoai's ComfyUI-SizeFromPresets, a tiny pack that reads size presets from a CSV file and turns them into w/h numbers and/or latents. No models, no weights, no API - just pure Python. The same author also makes the widely-liked ComfyUI-SaveImageWithMetaData, and this pack has that same "small, does one thing, gets out of the way" feel.

    How it works

    The mechanism is embarrassingly simple, which is why it's reliable. On generate, the node seeds NumPy's default_rng with your seed, calls choice() on the five preset strings, parses the winner, and builds a zero latent:

    latent = torch.zeros([batch_size, 4, h // 8, w // 8])
    

    An "empty latent" is just a block of zeros at 1/8 the pixel dimensions - the sampler adds the noise later. Nothing is generated here; you're choosing a canvas, not a picture.

    The inputs that matter

    • seed - this is the one you'll actually touch. Same seed, same size, every time.
    • batch_size - 1 to 4096, how many identical empty latents to stack. Leave it at 1 unless you're doing batch workflows.

    That's it. No preset dropdown - random means all five: 512x512, 768x512, 512x768, 716x403, 403x716. Outputs are latent (wire into the sampler's latent input) plus w and h as INTs, which you can route into conditioning or just read for metadata.

    Where people get burned

    The seed is sticky. A widget seed defaults to 0 and stays 0 until the seed actually changes. If you hit queue ten times, you get the same size ten times - "random" doesn't randomize unless the seed changes. Use the widget's randomize/control-after-generate toggle or wire in a seed that changes per run. Once you do, you get the dice-roll behavior you signed up for.

    One preset lies about its size. 716x403 isn't divisible by 8, so 716 // 8 floors to 89 and the latent decodes to 712x400 - the w/h outputs say 716x403, but the actual image won't. Harmless for most people, maddening if you were relying on exact pixels. The other four presets are clean.

    You can't filter the dice. Portrait results are in the pool, and with 2 of 5 presets portrait you'll see them constantly. If you only ever want landscape, edit presets/sd15.csv down to the sizes you want (see below).

    Install and troubleshooting

    Easiest route is ComfyUI Manager - search "ComfyUI-SizeFromPresets" and install. Or clone it:

    cd <ComfyUI>/custom_nodes
    git clone https://github.com/nkchocoai/ComfyUI-SizeFromPresets.git
    

    Then restart ComfyUI. There's no requirements.txt - the pack only uses csv, numpy, and torch, all of which ComfyUI already ships. Nothing to download.

    Two gotchas worth knowing. First, the presets are read from disk once at import time, so after editing presets/sd15.csv you must restart ComfyUI to see the changes. Second, the code hardcodes the folder name ComfyUI-SizeFromPresets when locating that CSV - don't rename the clone, or the nodes fail to load. Keep a copy of the CSV before you edit it, because a malformed file breaks startup for the whole pack.

    CategorySizeFromPresets

    Inputs (2)

    NameTypeDefaultDescription
    batch_sizeINT11–4096
    seedINT00–18446744073709550000

    Outputs (3)

    NameTypeDescription
    latentLATENT
    wINT
    hINT