From 1c7e32d8affc66d87784a40bdaf4433f4753ad1a Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Mon, 22 Sep 2025 15:34:48 +0300 Subject: [PATCH] Support lucy edit --- nodes.py | 21 +++++++++++++++++++++ nodes_sampler.py | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/nodes.py b/nodes.py index 0956ec3..8e265dc 100644 --- a/nodes.py +++ b/nodes.py @@ -1230,6 +1230,25 @@ class WanVideoAddExtraLatent: updated = dict(embeds) updated["extra_latents"] = extra_latents_list return (updated,) + +class WanVideoAddLucyEditLatents: + @classmethod + def INPUT_TYPES(s): + return {"required": { + "embeds": ("WANVIDIMAGE_EMBEDS",), + "extra_latents": ("LATENT",), + } + } + + RETURN_TYPES = ("WANVIDIMAGE_EMBEDS",) + RETURN_NAMES = ("image_embeds",) + FUNCTION = "add" + CATEGORY = "WanVideoWrapper" + + def add(self, embeds, extra_latents): + updated = dict(embeds) + updated["extra_channel_latents"] = extra_latents["samples"] + return (updated,) class WanVideoMiniMaxRemoverEmbeds: @classmethod @@ -2126,6 +2145,7 @@ NODE_CLASS_MAPPINGS = { "WanVideoRoPEFunction": WanVideoRoPEFunction, "WanVideoAddPusaNoise": WanVideoAddPusaNoise, "WanVideoAnimateEmbeds": WanVideoAnimateEmbeds, + "WanVideoAddLucyEditLatents": WanVideoAddLucyEditLatents, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -2163,4 +2183,5 @@ NODE_DISPLAY_NAME_MAPPINGS = { "WanVideoRoPEFunction": "WanVideo RoPE Function", "WanVideoAddPusaNoise": "WanVideo Add Pusa Noise", "WanVideoAnimateEmbeds": "WanVideo Animate Embeds", + "WanVideoAddLucyEditLatents": "WanVideo Add LucyEdit Latents", } diff --git a/nodes_sampler.py b/nodes_sampler.py index 234d2d3..e9894c6 100644 --- a/nodes_sampler.py +++ b/nodes_sampler.py @@ -791,6 +791,11 @@ class WanVideoSampler: noise_multipliers[idx] = noise_multiplier_list[i] log.info(f"Using Pusa noise multipliers: {noise_multipliers}") + # lucy edit + extra_channel_latents = image_embeds.get("extra_channel_latents", None) + if extra_channel_latents is not None: + extra_channel_latents = extra_channel_latents[0].to(noise) + latent = noise.to(device) #controlnet @@ -1171,6 +1176,14 @@ class WanVideoSampler: humo_audio_input_neg = None else: humo_audio_input = humo_audio_input_neg = None + + if extra_channel_latents is not None: + if context_window is not None: + extra_channel_latents_input = extra_channel_latents[:, context_window].to(z) + else: + extra_channel_latents_input = extra_channel_latents.to(z) + z = torch.cat([z, extra_channel_latents_input]) + base_params = { 'x': [z], # latent 'y': [image_cond_input] if image_cond_input is not None else None, # image cond