Nodes/ComfyUI-nodes-hnmr/RandomLatentImage
ComfyUI Node

RandomLatentImage

RandomLatentImage

By CYBERLOOM-INC·Created 3 years ago·Updated 2 years ago· 11
RandomLatentImage
    • LATENT
    width512
    height512
    batch_size1

    EmptyLatentImage gives you a blank latent to start from. RandomLatentImage gives you one that's already full of Gaussian noise - a latent of torch.randn values instead of zeros - and if you've ever wondered what the difference is, it matters for img2img-style workflows and for anyone who likes starting generations from a genuinely fresh random state.

    The inputs are width (64–4096, default 512, stepping by 64), height (same), and batch_size (1–64, default 1). Output is a standard LATENT shaped (batch, 4, height/8, width/8) - 4 channels, one eighth the resolution, exactly what a VAE and sampler expect. The mechanism is a single line: torch.randn(batch, 4, h//8, w//8).

    So why not just use EmptyLatentImage? With a normal KSampler, the sampler adds fresh noise to the latent on its own when it runs, so an empty start and a random start often converge to the same behavior. Where RandomLatentImage earns its place is when you're sampling with denoise below 1 - img2img, inpainting, or any "keep part of the structure, re-randomize the rest" pass - where the pre-existing noise interacts with the image content instead of being discarded. It's also a neat way to get visibly different starts when chaining or iterating over latents in a custom loop.

    Honestly, for vanilla text-to-image you can skip it; a plain EmptyLatentImage plus a sampler is the more predictable default. Reach for this when you're doing variations, iterations, or latent-level experimentation and you want the starting point itself to be explicitly random.

    Install the pack via ComfyUI Manager (search "ComfyUI-nodes-hnmr") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr
    

    Restart ComfyUI. No models to download, no requirements.txt - this node is pure torch.

    One thing to keep in mind: it doesn't take a seed. Each run draws fresh random noise, so if you're hunting a specific result and want reproducibility, pair it with a KSampler whose seed you control - or just accept the randomness, since that's the point of the node. Dimensions step by 64 and clamp to the 64–4096 range, so no weird sizes sneak through. This is part of the maintained fork of hnmr293's pack, so if ComfyUI complains it can't find the node, make sure you installed the CYBERLOOM-INC repo and not the abandoned original.

    Categorylatent

    Inputs (3)

    NameTypeDefaultDescription
    widthINT51264–4096
    heightINT51264–4096
    batch_sizeINT11–64

    Outputs (1)

    NameTypeDescription
    LATENTLATENT