Random Empty Latent Image From Presets (SDXL)
SDXL, but the aspect ratio is a surprise
- latent
- w
- h
The SDXL version of the pack's random-latent node: give it a seed, and it rolls one of SDXL's nine trained resolutions, builds an empty latent at that size, and hands you the latent, w, and h. Drop it where you'd use the core Empty Latent Image and every queue gets a different frame - a great way to shake up compositions, hunt for a ratio that suits a prompt, or batch-produce variation grids without manually editing a size widget between runs.
It comes from nkchocoai's ComfyUI-SizeFromPresets, a zero-fuss pack that turns CSV-stored size presets into widths, heights, and empty latents. No weights, no API, no extra Python packages - the author keeps it deliberately tiny.
How it works
Identical mechanism to the other random nodes in the pack, which is why it's so predictable once you understand the seed:
random_gen = np.random.default_rng(seed)
preset = random_gen.choice(self.SIZE_PRESETS_INPUT)
latent = torch.zeros([batch_size, 4, h // 8, w // 8])
The RNG is seeded purely from your seed, so the same seed always picks the same preset. The latent is a block of zeros at 1/8 resolution - you're choosing a canvas, not generating content. The sampler adds noise later.
The pool is the nine SDXL presets: 1024x1024, 1152x896, 896x1152, 1216x832, 832x1216, 1344x768, 768x1344, 1536x640, 640x1536. Every one is ~1MP and divisible by 8, so unlike the SD1.5 sibling there's no size-mismatch quirk - the latent always decodes to exactly the advertised dimensions. It's also why a "random" size here is safe VRAM-wise: all nine options sit in the same pixel budget, so your batch isn't going to balloon into an OOM because the dice rolled a monster canvas.
The inputs that matter
seed- the whole game. Fixed seed, fixed size.batch_size- 1 to 4096, stacked empty latents. Default 1.
Outputs: latent into the sampler, w/h INTs for conditioning or display.
Where people get burned
Same two traps as the whole family. The seed must change for the size to change - a widget stuck at 0 queues the same size every time, so "random" only happens if you randomize the seed (control-after-generate) or feed in a changing one.
And portrait is in the pool. With 832x1216 and 640x1536 available, expect portrait frames regularly. If your downstream workflow assumes landscape, either check w/h before sampling or edit the CSV to drop the orientations you don't want.
Install and troubleshooting
ComfyUI Manager, search "ComfyUI-SizeFromPresets", install, restart. Or clone:
cd <ComfyUI>/custom_nodes
git clone https://github.com/nkchocoai/ComfyUI-SizeFromPresets.git
No requirements.txt - the pack uses only numpy, torch, and the csv standard library that ComfyUI already ships. If you want to change what "random" can roll, edit presets/sdxl.csv and restart: the list loads once at import. Keep the folder named ComfyUI-SizeFromPresets - the code locates the CSV by that exact path, so renaming the clone breaks the pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| batch_size | INT | 11–4096 | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| w | INT | — |
| h | INT | — |