Skip to content

Commit

Permalink
fix: ltxv crop guides works with 0 keyframes (#7085)
Browse files Browse the repository at this point in the history
This patch fixes a bug in LTXVCropGuides when the latent has no
keyframes. Additionally, the first frame is always added as a keyframe.

Co-authored-by: Andrew Kvochko <[email protected]>
  • Loading branch information
kvochko and Andrew Kvochko authored Mar 5, 2025
1 parent 6d45ffb commit 872780d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions comfy_extras/nodes_lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ def generate(self, positive, negative, vae, latent, image, frame_idx, strength):
frame_idx, latent_idx = self.get_latent_index(positive, latent_length, frame_idx, scale_factors)
assert latent_idx + t.shape[2] <= latent_length, "Conditioning frames exceed the length of the latent sequence."

if frame_idx == 0:
latent_image, noise_mask = self.replace_latent_frames(latent_image, noise_mask, t, latent_idx, strength)
return (positive, negative, {"samples": latent_image, "noise_mask": noise_mask},)


num_prefix_frames = min(self._num_prefix_frames, t.shape[2])

positive, negative, latent_image, noise_mask = self.append_keyframe(
Expand Down Expand Up @@ -252,6 +247,8 @@ def crop(self, positive, negative, latent):
noise_mask = get_noise_mask(latent)

_, num_keyframes = get_keyframe_idxs(positive)
if num_keyframes == 0:
return (positive, negative, {"samples": latent_image, "noise_mask": noise_mask},)

latent_image = latent_image[:, :, :-num_keyframes]
noise_mask = noise_mask[:, :, :-num_keyframes]
Expand Down

0 comments on commit 872780d

Please sign in to comment.