Fix load latent compatibility with ComfyUI-saved latent files
ComfyUI saves latents under key 'latent_tensor', remap to 'samples' so downstream nodes get the expected LATENT dict format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -77,11 +77,17 @@ class LoadLatentAbsolute:
|
||||
def load(self, path):
|
||||
path = os.path.expanduser(path)
|
||||
|
||||
samples = safetensors.torch.load_file(path, device="cpu")
|
||||
raw = safetensors.torch.load_file(path, device="cpu")
|
||||
|
||||
with safetensors.safe_open(path, framework="pt") as f:
|
||||
meta = f.metadata()
|
||||
|
||||
# ComfyUI's built-in save latent uses key "latent_tensor" → remap to "samples"
|
||||
if "latent_tensor" in raw and "samples" not in raw:
|
||||
raw["samples"] = raw.pop("latent_tensor")
|
||||
|
||||
samples = dict(raw)
|
||||
|
||||
# Restore original devices
|
||||
if meta and "devices" in meta:
|
||||
devices = json.loads(meta["devices"])
|
||||
|
||||
Reference in New Issue
Block a user