ComfyUI Node

Load Latent EXR

Read an exact latent state back into the sampler

By spacepxl·Created 3 years ago·Updated 6 months ago· 102
Load Latent EXR
    • samples
    • batch_size
    filepathpath to directory or .exr file
    image_load_cap0
    skip_first_images0
    select_every_nth1

    This is the read side of the pack's latent round-trip. SaveLatentEXR writes a latent tensor out as a 4-channel 32-bit float EXR; this node loads one back and hands you a LATENT that's ready to feed a sampler, an img2img pass, or a refine loop. The whole point is that nothing gets lost between save and load - no PNG quantization, no VAE encode/decode drift. If you saved it, you get it back exactly.

    Reach for it when you want to interrupt a big batch, pick up a specific generation state days later, or move latents between projects without rerunning the sampler that made them. The VAE-decode round trip is lossy and costs you quality on every pass; skipping it entirely is the whole appeal.

    How it works

    EXR is the only mainstream format this works with, because latents are float values that go negative and carry way more precision than 8-bit pixels. The loader reads the file with OpenCV's unchanged float mode, reorders the RGBA channels back to the order the sampler expects (the exact inverse of what SaveLatentEXR does on the way out), and reshapes into the (batch, 4, H, W) latent layout ComfyUI wants. Then it wraps it in the standard {"samples": ...} dict and returns it as samples.

    Like LoadEXR, it accepts a single file or a folder of them, with the same VHS-style batch controls: image_load_cap (0 = everything), skip_first_images, and select_every_nth. Outputs are samples (LATENT) and batch_size (INT).

    Wire samples into the latent input of a KSampler and you're sampling from a restored state - which is a genuinely different workflow from loading a PNG and encoding it, because you're skipping a lossy encode too.

    The 4-channel caveat, repeated

    Everything about this node assumes the SD 1.5 / SDXL latent layout: four channels, (B, 4, H, W). That matches what SaveLatentEXR writes. It does not match Flux (16 channels) or the newer video models. If you save a Flux latent with this pack, the load will only bring back four channels and the rest is gone. For SD-family models it's exact; for anything else, check the channel count first.

    Install

    Part of spacepxl's ComfyUI-HQ-Image-Save: ComfyUI Manager → search ComfyUI-HQ-Image-Save → install → restart, or clone https://github.com/spacepxl/ComfyUI-HQ-Image-Save into custom_nodes/. Dependencies are imageio and opencv-python only, no models.

    Pair it with the obvious

    SaveLatentEXR on the way out, LoadLatentEXR on the way in, same filename conventions, same channel order. If you hit the "OpenEXR codec is disabled" error on load, that's your OpenCV build missing the EXR codec - the standard opencv-python wheel includes it, and the pack enables it at import.

    CategoryHQ-Image-Save

    Inputs (4)

    NameTypeDefaultDescription
    filepathSTRINGpath to directory or .exr file
    image_load_capoptINT0
    skip_first_imagesoptINT0
    select_every_nthoptINT1

    Outputs (2)

    NameTypeDescription
    samplesLATENT
    batch_sizeINT