From b3d5b25b697d6000677dfe51ad9bc77d5adb4d92 Mon Sep 17 00:00:00 2001 From: Eugene Fairley Date: Wed, 23 Jul 2025 17:23:52 -0700 Subject: [PATCH] Scale inputs before and after motion patch --- comfy_extras/nodes_wan.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/comfy_extras/nodes_wan.py b/comfy_extras/nodes_wan.py index 38ca17c63..3ee5bca87 100644 --- a/comfy_extras/nodes_wan.py +++ b/comfy_extras/nodes_wan.py @@ -711,12 +711,16 @@ class WanTrackToVideo: res = res.permute(1,2,3,0)[:, :, :, :3] # T, H, W, C y = vae.encode(res) + # Scale latent since patch_motion is non-linear + y = comfy.latent_formats.Wan21().process_in(y) c = torch.cat((msk, y), dim=1) res = patch_motion( processed_tracks, c[0], temperature=temperature, topk=topk, vae_divide=(4, 16) ) msk, y = res + y = comfy.latent_formats.Wan21().process_out(y) + msk = -msk + 1.0 # Invert mask to match expected format positive = node_helpers.conditioning_set_values(positive, {"tracks": processed_tracks,