Nodes/ComfyUI-JDCN/JDCN_BatchLatentLoadFromDir
ComfyUI Node

JDCN_BatchLatentLoadFromDir

Re-open your saved latents straight from a folder

By daxcayΒ·Created 2 years agoΒ·Updated about a year agoΒ· 159
JDCN_BatchLatentLoadFromDir
    • Latent
    • Latent_Names
    • Latent_Paths
    • Load_Cap
    • Skip_Frame
    • Count
    β—„Directorydirectory pathβ–Ί
    β—„Load_Cap1β–Ί
    β—„Skip_Frame0β–Ί

    JDCN_BatchLatentLoadFromDir loads latent files - the .latent format written by this pack's JDCN_BatchSaveLatent - from a folder, as a batch. It's the read side of a save/load pair, and its whole reason to exist is the animation/video workflow: VAE-encode your frames once, save the latents, then sample again and again without re-encoding.

    Why the pair exists

    In video and animation work, the VAE encode of a frame sequence is real, repeated cost - you're pushing every frame through the encoder each time you want to try a different prompt or sampler. Encoding once, dumping the result to disk, and reloading later sidesteps that entirely. The trade-off is disk space (latents are chunky), but for iterative anim work it's often the difference between "fiddle with the prompt for five minutes" and "fiddle for twenty."

    How it works

    Three inputs, same shape as the image loader:

    • Directory - where the .latent files live.
    • Load_Cap - how many latents to load.
    • Skip_Frame - skip the first N files.

    It scans the folder for .latent files only (this format is this pack's own - comfy.utils.save_torch_file with a latent_tensor key, so don't expect it to read arbitrary checkpoint latents), then loads the slice after Skip_Frame, up to Load_Cap.

    Outputs mirror the image loader: Latent (list of LATENT), Latent_Names, Latent_Paths, plus Load_Cap, Skip_Frame, and Count. Wire Latent straight into your sampler's latent input (it expects a latent dict, which is what gets saved/loaded).

    The honest caveats

    Same unsorted OS order gotcha as every folder node in this pack - if your _0001, _0002 ... _0010 latents load out of order, it's the folder walk, not you. And the Skip_Frame/Load_Cap slicing is positional over whatever order the walk produced. Zero-padded names are your friend.

    Also, a loaded latent carries no metadata about the source image - you get the latent and its name/path, not the prompt that made it. Keep your own naming conventions sane (the saver's FilenamePrefix helps here) or you'll be guessing which batch is which later.

    Installing it

    Part of ComfyUI-JDCN:

    • ComfyUI Manager β†’ Install Custom Node β†’ search JDCN β†’ install ComfyUI-JDCN β†’ restart.
    • Or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN.git
    cd ComfyUI-JDCN
    pip install -r requirements.txt
    

    Restart; under πŸ”΅ JDCN πŸ”΅. Only dependency is piexif, no models to download.

    Common issues

    Point it at a folder with no .latent files and you get empty outputs plus a console note - the UI stays quiet, so check the log. Corrupt or mismatched latent files (e.g. saved by a different tool with a different tensor layout) can error during load; the node catches per-file errors and skips them, but verify one load end-to-end before running a big batch. And don't forget the VAE rule that applies to everything latent-related: the decode will only look right if the checkpoint you sample with matches the latent's origin. If colors come back weird, the model you loaded doesn't match what you encoded - not a bug in this node.

    CategoryπŸ”΅ JDCN πŸ”΅

    Inputs (3)

    NameTypeDefaultDescription
    DirectorySTRINGdirectory pathβ€”
    Load_CapINT11–9999β€”
    Skip_FrameINT00–9999β€”

    Outputs (6)

    NameTypeDescription
    LatentLATENTβ€”
    Latent_NamesSTRINGβ€”
    Latent_PathsSTRINGβ€”
    Load_CapINTβ€”
    Skip_FrameINTβ€”
    CountINTβ€”