Skip to content

Commit c104d04

Browse files
committed
Removed Redundant Code
1 parent fbd8e19 commit c104d04

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "WanVideoLooper"
33
description = "This is a set of custom nodes for ComfyUI designed for generating sequential long video clips based on the Wan 2.2 model architecture, handling continuity between segments and offering advanced control over the sampling process"
4-
version = "1.0.6"
4+
version = "1.0.7"
55
license = {file = "LICENSE"}
66
dependencies = [
77
"color-match",

wan_looper_node.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _prepare_latent_window(positive_cond, negative_cond, vae, width, height, fra
111111
return positive_cond, negative_cond, {"samples": empty_latent}
112112

113113
# ====================================================================================================
114-
# NEW Color Match Helper
114+
# Color Match Helper
115115
# ====================================================================================================
116116
def _apply_color_match(target_batch_tensor, reference_tensor, strength=1.0):
117117
"""Applies MKL color matching from reference to target batch."""
@@ -131,6 +131,8 @@ def _apply_color_match(target_batch_tensor, reference_tensor, strength=1.0):
131131
cm = ColorMatcher()
132132

133133
for i in range(batch_size):
134+
if (i + 1) % 25 == 0 or i == 0: # Log every 25 frames
135+
_log(f"Color matching frame {i+1}/{batch_size}...")
134136
try:
135137
target_img = target_np[i]
136138
transfer_result = cm.transfer(src=target_img, ref=ref_np, method='mkl')
@@ -389,20 +391,16 @@ def loop_video(
389391
# --- 4. Finalize & Return ---
390392
if not all_frames_collected:
391393
_log("Error: No frames were collected."); return (torch.zeros((1, 64, 64, 3)),)*2
392-
_log("Concatenating final video batch.")
393-
num_channels = all_frames_collected[0].shape[-1]
394-
consistent_batches = []
395-
for batch in all_frames_collected:
396-
if batch.shape[-1] == num_channels: consistent_batches.append(batch)
397-
else:
398-
_log(f"Warning: Channel mismatch found (Expected {num_channels}, Got {batch.shape[-1]}). Adjusting batch.")
399-
if batch.shape[-1] == 1 and num_channels == 3: batch = batch.repeat(1, 1, 1, 3)
400-
elif batch.shape[-1] == 4 and num_channels == 3: batch = batch[:, :, :, :3]
401-
elif batch.shape[-1] == 3 and num_channels == 4: alpha = torch.ones_like(batch[:, :, :, :1]); batch = torch.cat([batch, alpha], dim=-1)
402-
else: batch = torch.zeros((batch.shape[0], batch.shape[1], batch.shape[2], num_channels), dtype=batch.dtype)
403-
consistent_batches.append(batch)
404-
405-
final_batch = torch.cat(consistent_batches, dim=0)
394+
395+
_log("Concatenating final video batch...")
396+
try:
397+
final_batch = torch.cat(all_frames_collected, dim=0)
398+
399+
except RuntimeError as e:
400+
_log(f"CRITICAL ERROR: Failed to concatenate final batch. This may be a channel/shape mismatch between segments. {e}")
401+
_log("This should not happen if the VAE is consistent. Please report this error.")
402+
_log("Returning a dummy tensor to prevent a crash.")
403+
return (torch.zeros((1, 64, 64, 3)),)*2
406404

407405
# --- 4b. Final Frame Color Match (New Logic) ---
408406
if color_match and color_match_lastframe and final_batch.shape[0] > 1:

0 commit comments

Comments
 (0)