ComfyUI Node

Empty Latent

Aspect ratios, a 50/50 dimension swap, and batch size in one node

By loz2754·Created 8 months ago·Updated about 22 hours ago· 5
Empty Latent
    • latent
    • width
    • height
    • seed
    width720
    height720
    aspect_ratio
    modefixed
    swap_dimensionsNo
    batch_size1
    seed0

    Every txt2img pipeline starts the same way: generate an empty latent, feed it to the sampler. ComfyUI's stock Empty Latent Image does the job, but it's a bare pair of width/height fields. AUNEmptyLatent is the pack's version, and it layers on three things the stock node lacks: a dropdown of predefined aspect ratios, a dimension-swap mode that randomly flips orientation, and batching. If you've ever wanted a "random aspect ratio roulette" workflow, this is the node that makes it trivial.

    The main inputs are width and height (64–8192, default 720×720) - but the star is aspect_ratio, which lists 14 presets: 512x512, 720x720, 1024x1024 for squares; 512x682, 512x768, 910x512, 952x512, 1024x512 for the landscape/portrait side of the family; and 640x1536, 768x1344, 832x1216, 896x1152 for the tall, SDXL-style portrait buckets. Pick one and it overwrites width/height; pick custom and it defers to the two numeric fields. This is a huge quality-of-life win if you're tired of typing 832x1216 from memory.

    Then the random stuff. mode has two options: fixed uses the dimensions exactly as given, while random gives a 50% chance of swapping width and height each run - so with aspect_ratio set to a portrait bucket, half your batch comes out landscape. swap_dimensions (Yes/No) is the explicit, non-random version: flip orientation by hand. batch_size (1–64) sets how many latent images you generate in one go, which is how you run an entire batch of seeds at the same resolution. And seed seeds the random generator, so you can make the coin-flip reproducible when you need to.

    The outputs are the load-bearing part for automation: latent (the LATENT you feed the KSampler), plus width, height, and seed as INTs. Wiring those numbers into a filename builder or a save node means your filenames always know the actual dimensions that ran - important in random mode, where you can't guess them from the node face.

    Mechanically it's the standard ComfyUI empty latent - torch.zeros shaped [batch_size, 4, H//8, W//8], the 8× compression every latent-based model expects - with the ratio and swap logic layered on top. The IS_CHANGED hook forces a re-execution in random mode, so the coin actually flips per run instead of ComfyUI caching the old latent.

    From the AUN pack: ComfyUI Manager (search "AUN") or cd ComfyUI/custom_nodes && git clone https://github.com/loz2754/AUN-ComfyUI-Nodes, then restart. No model downloads, dependency-light. If your workflow always regenerates the same square and you keep editing the numbers, switch to a preset and thank yourself later.

    CategoryAUN Nodes/Image

    Inputs (7)

    NameTypeDefaultDescription
    widthINT72064–8192The width of the latent image.
    heightINT72064–8192The height of the latent image.
    aspect_ratioCOMBOChoose a predefined aspect ratio, or 'custom' to use the width and height inputs.
    modeCOMBOfixedIn 'random' mode, there's a 50% chance of swapping width and height. In 'fixed' mode, the dimensions are used as specified.
    swap_dimensionsCOMBONoExplicitly swap the width and height dimensions.
    batch_sizeINT11–64The number of latent images to generate in a batch.
    seedINT00–18446744073709550000The seed for the random number generator.

    Outputs (4)

    NameTypeDescription
    latentLATENT
    widthINT
    heightINT
    seedINT