From c5d23a7c384c9c1c708938ac954f5987f3561d96 Mon Sep 17 00:00:00 2001 From: ozbayb <17261091+ozbayb@users.noreply.github.com> Date: Sat, 8 Feb 2025 11:48:10 -0700 Subject: [PATCH] Enable handling of sub-steps in LeapfusionHunyuanI2V patch method --- nodes/nodes.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nodes/nodes.py b/nodes/nodes.py index 2e343a0..1e899eb 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -2250,7 +2250,17 @@ class LeapfusionHunyuanI2V: def unet_wrapper(apply_model, args): steps = args["c"]["transformer_options"]["sample_sigmas"] inp, timestep, c = args["input"], args["timestep"], args["c"] - current_step_index = (steps == timestep).nonzero().item() + matched_step_index = (steps == timestep).nonzero() + if len(matched_step_index) > 0: + current_step_index = matched_step_index.item() + else: + for i in range(len(steps) - 1): + # walk from beginning of steps until crossing the timestep + if (steps[i] - timestep) * (steps[i + 1] - timestep) <= 0: + current_step_index = i + break + else: + current_step_index = 0 current_percent = current_step_index / (len(steps) - 1) if samples is not None: if start_percent <= current_percent <= end_percent: