From 711d5b09c63b90e64e803ca6af7d94b13355165a Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:45:56 -0500 Subject: [PATCH] Attempt to fix hooks being disabled at first step of second sampler Still invokes the ModelPatcher when it shouldn't need to. Causes very slight difference in results, but not nearly as much. --- comfy/hooks.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/comfy/hooks.py b/comfy/hooks.py index b6f0ac213..82f4db098 100644 --- a/comfy/hooks.py +++ b/comfy/hooks.py @@ -432,8 +432,12 @@ class HookKeyframeGroup: return False prev_index = self._current_index prev_strength = self._current_strength - # if met guaranteed steps, look for next keyframe in case need to switch - if self._current_used_steps >= self._current_keyframe.guarantee_steps: + if ( + # if met guaranteed steps, look for next keyframe in case need to switch + self._current_used_steps >= self._current_keyframe.guarantee_steps + # handle case where guarantee_steps is 1 at first keyframe, but later steps have already occurred + or bool(self._current_keyframe == self.keyframes[0] and self.keyframes[1].start_t >= curr_t) + ): # if has next index, loop through and see if need to switch if self.has_index(self._current_index+1): for i in range(self._current_index+1, len(self.keyframes)):