Nodes/JosiaNodes/Josia加载Latent
ComfyUI Node

Josia加载Latent

Read a .latent back, resize it, and rescue a VAE decode that died

By Josia-doit·Created 6 months ago·Updated a day ago· 18
Josia加载Latent
  • Latent
  • Latent
Latent文件🎞️ 请选择 .latent 文件…
Latent缩放false
缩放比例2.00
对齐倍数16

A PNG is not just pixels in this ecosystem - it carries the whole graph that made it (image-io-metadata.md). A .latent file is the opposite: no workflow, no prompt, just the tensor your sampler was pushing around. That makes it boring, and it also makes it the one artifact you can rescue a run from after VAE decode eats your VRAM (troubleshooting.md).

Josia加载Latent (JosiaLoadLatent) is the read-back half of that idea. Save a latent with the pack's media-save node, load it here, optionally scale it, and hand it to a decoder or a second sampler.

What it actually is

The latent is the compressed representation the diffusion model works in - the VAE converts between that and pixels, roughly 8× per side for most modern VAEs (concepts.md). Sampling happens in that space, so a .latent is a snapshot of the expensive part of a run, already done.

Two things that's good for. Two-pass work: scale the latent up, feed it into a second KSampler at low denoise, and you get hi-res-fix behaviour instead of resampling from pixels (upscaling.md). And the reason this node exists - the pack's Josia媒体保存 writes the .latent to disk before it decodes, so a decode OOM doesn't lose the run.

The inputs that matter

The file picker is Latent文件, a STRING listing .latent files from ComfyUI/input/josia_latent/. You don't have to own any of them: the 📁 选择文件 button uploads a .latent from anywhere on disk into that folder.

Latent缩放 is the switch (default off = strict pass-through, not a single dimension touched), and when it's on you set 缩放比例 (default 2.0, range 0.1–8) and 对齐倍数 (1/2/4/8/16/32/64/128, default 16). The multiplier is applied to the spatial H and W only; the alignment then rounds the result up to a multiple of that number. Up, never down - the author is explicit that rounding down would irreversibly crop information, and 16 is the safe default because most VAEs and patch pipelines want 8 or 16.

There's also an optional Latent input, and it quietly changes what the node is: wire something into it and the file is ignored entirely. Now it's a pass-through/scale node you can drop mid-graph instead of a separate latent resize node. Note the Latent缩放 switch still decides - on scales, off passes straight through.

Output is a single Latent. Wire it into VAEDecode to see pixels, or into a sampler's latent input for a second pass.

How the resize works, and where it stops

Image latents [B,C,H,W] and video latents [B,C,T,H,W] get bilinear interpolation on the last two dimensions only - frames and channels untouched. Joint audio-video latents (the nested-tensor kind LTX-2 and MiniMax H3 produce, where picture and sound share one latent space - ltx-video.md) are the interesting case: it splits the parts, scales the video path, leaves audio alone, and re-mixes. If the re-mix fails you get a clear error instead of a mangled tensor. Pure audio latents can't be scaled at all, and the node says so rather than guessing.

Install

ComfyUI Manager, search for ComfyUI_JosiaNodes, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Josia-doit/ComfyUI_JosiaNodes
# restart ComfyUI

No pip step. requirements.txt in the repo is empty apart from a comment - everything here runs on libraries ComfyUI already bundles (torch, numpy, Pillow), and the read path falls back to plain torch.load even if safetensors is missing. Restart and look for a console line starting with [JosiaNodes] ✅. The README says to expect "注册节点数:15"; current 1.8.0 registers 17, so don't panic at the number - the line appearing is what matters.

Worth knowing: the author's README says this pack ships mainly through GitHub and doesn't promise passage through the registry's automatic security scan (older versions were flagged). If Manager can't find it, clone it.

Where people will get burned

Scaling a latent does not add detail. Interpolating the tensor and then decoding gives you a soft, slightly wrong bigger image. The scale is the setup for a second sampler pass - run it at denoise 0.3–0.5, and higher just regenerates (upscaling.md).

"找不到文件" almost always means the file isn't where the node looks. It searches input/josia_latent/, then the input/ root - an absolute path typed into the widget won't work. Use the upload button and let it copy the file in.

The .latent doesn't contain a mask. It stores the tensor plus a format-version marker, same as ComfyUI's native Save Latent. Save an inpainting latent, reload it, and the noise_mask is gone - if region-constrained sampling is what you need, restart from the sampler, not from the file.

Files are read by magic bytes, not extension - the head is checked for a safetensors signature before falling back to torch.load, which is why it doesn't trip the "Weights only load failed" error a naive loader hits on a .latent. A truncated file fails loudly at load time; if you see that, the write was interrupted.

Category⚡️JosiaNodes

Inputs (5)

NameTypeDefaultDescription
Latent文件STRING🎞️ 请选择 .latent 文件…要加载的 .latent 文件名;用「📁 选择文件」上传新文件后自动填入。
Latent缩放BOOLEANfalse开启后按下方「缩放比例 / 对齐倍数」放大潜空间;关闭则原样加载。
缩放比例FLOAT2.000.1–8空间尺寸(宽高)的放大倍数,默认 2.0;1.0 = 不改变。
对齐倍数COMBO16把放大后的宽高**向上**对齐到该倍数的整数倍(VAE / patch 通常需要 8 或 16 的倍数,默认 16)。只向上补、绝不因对齐把潜空间缩小。1 = 不对齐。
LatentoptLATENT接入后忽略「Latent文件」,直接对上游 Latent 处理:「Latent缩放」开=按缩放比例/对齐倍数放大,关=原样透传。

Outputs (1)

NameTypeDescription
LatentLATENT读回(并按需放大)的潜空间。