Random Size From Presets (SD1.5)
Random SD1.5 sizes with zero extra nodes
- w
- h
The SD1.5 flavor of the pack's random-size node: give it a seed, get back w and h - the size of one of SD1.5's five presets, chosen at random. No latent, no batch, just numbers you can feed into an Empty Latent Image, a resize node, or anything else that wants explicit dimensions. It's the smallest tool in nkchocoai's ComfyUI-SizeFromPresets pack, and it exists so you can put a "surprise size" into a workflow without building the plumbing yourself.
It's a genuinely handy thing for variation workflows. Run the same prompt over and over with a changing seed and you'll get a mix of squares, 3:2-ish frames, and portraits - a fast way to see which composition a prompt actually wants before you commit to a size. For SD1.5, where generation is cheap, that kind of exploration is almost free.
How it works
Deterministic randomness, which sounds contradictory and isn't:
random_gen = np.random.default_rng(seed)
preset = random_gen.choice(self.SIZE_PRESETS_INPUT)
w, h = [int(v.strip()) for v in preset.split('x')]
NumPy's default_rng seeded with your seed picks one of the five presets from presets/sd15.csv: 512x512, 768x512, 512x768, 716x403, 403x716. Same seed, same size, forever. That reproducibility is the point - a workflow that "rolls" a size still replays exactly when you keep the seed.
The one input
seed- that's the entire interface. Default 0, up to0xffffffffffffffff.
Outputs: w, h - INTs, in that order. There's no batch_size because there's nothing to batch.
Where people get burned
The family curse: the seed has to actually change for the size to change. A widget seed parked at 0 returns the same size on every queue. "Random" only happens when the seed value changes between runs - flip on the widget's randomize (control-after-generate) or wire in a changing seed. This is the #1 confusion with every node in this pack, and it's not obvious from the node name.
Also remember the pool includes portrait (512x768, 403x716) and the oddball 716x403 - which is 16:9-ish but not divisible by 8. If you wire these numbers into a latent generator, 716x403 floors to a 712x400-decoding canvas, so the w/h this node reports won't match the actual image size for that one preset. The other four are exact.
Install
ComfyUI Manager, search "ComfyUI-SizeFromPresets", install, restart. Or:
cd <ComfyUI>/custom_nodes
git clone https://github.com/nkchocoai/ComfyUI-SizeFromPresets.git
No requirements.txt, no model downloads - the pack needs only numpy, torch, and the csv standard library, all already in any ComfyUI environment. The preset list loads from presets/sd15.csv at startup; edit the file and restart to change what "random" can roll. And keep the clone named ComfyUI-SizeFromPresets - the code finds the CSV by that exact folder path, so renaming it breaks the pack.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| w | INT | — |
| h | INT | — |