DJZ Load Latent V2
Load latents by seed — batch-iterate through saved generations on autopilot
- samples
- current_file
The original DJZ Load Latent makes you click a dropdown. V2 is the version you point a loop at. Instead of selecting a file directly, you feed it a seed, and the node picks a latent by taking seed % number_of_files. Turn the seed up by one each run and it walks through every saved .latent file in your output directory, deterministically, no clicking.
Why you'd reach for it
Anything that cycles through saved generations in a loop. The killer workflow is batch processing: save a stack of latents, then run a second workflow N times with an incremented seed and get a different saved latent each time, all without touching the UI. It also fits animation-style pipelines where you want to chain previously-sampled latents frame by frame.
The numbered latent_index dropdown is a reference list - it shows you what's available (e.g. [0] filename.latent) so you can sanity-check what the seed math is about to hand you. It's cosmetic; the seed does the actual selecting.
How it works
Same guts as the original, plus the selection logic:
- Scan the output directory recursively for
.latentfiles. - Build the numbered reference list.
- Pick the file at position
seed % len(files). - Load via safetensors, apply the version-based scale (
1.0for v0,1.0 / 0.18215otherwise - the SD/SDXL VAE convention). - Return the tensor and the filename.
The modulo is the whole trick: with, say, 5 files on disk, seeds 0, 5, 10, 15 all load the same file. That's not a bug - it's how you get deterministic selection. If you want variety per run, step the seed by the file count, not by one.
The inputs that matter
- seed - an integer from 0 up to 2^64. It's your file selector and your loop driver in one.
- latent_index - read-only reference of what's on disk. The class name's "V2" shows up here too: this one tells you what it loaded.
Outputs
Two of them:
- samples (LATENT) - the loaded tensor, straight into a KSampler or latent-space node.
- current_file (STRING) - the filename that got loaded. Wire this to a text display or use it in a filename template so your saved outputs tell you which latent they came from. That's the output that makes the batch workflow actually auditable.
Installing it
It's one node in the DJZ-Nodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/DJZ-Nodes
cd DJZ-Nodes
pip install -r requirements.txt
Or ComfyUI Manager → search "DJZ-Nodes" → install. No model downloads involved.
Troubleshooting
- Dropdown says "No latents found". Straightforward - there are no
.latentfiles in the output directory yet. Save some first. - Same file over and over. You're stepping the seed by 1 with more than one file on disk; every
n-th seed hits the same index. Step by the file count, or use it deliberately for reproducible reruns. - Garbage output. A latent carries its VAE family with it, and the
1/0.18215scaling assumes SD/SDXL conventions. Loading a latent saved from an incompatible pipeline decodes to static. The node also returns a zero(1, 4, 8, 8)tensor on load failure rather than crashing - so if a run silently produces noise, check the console for the real error.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| latent_index | COMBO | 1 options: No latents found | |
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| samples | LATENT | — |
| current_file | STRING | — |