Swap mask and control_frames output order in MaskGenerator
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
24
nodes.py
24
nodes.py
@@ -26,10 +26,10 @@ class VACEMaskGenerator:
|
|||||||
CATEGORY = "VACE Tools"
|
CATEGORY = "VACE Tools"
|
||||||
FUNCTION = "generate"
|
FUNCTION = "generate"
|
||||||
RETURN_TYPES = ("IMAGE", "IMAGE", "INT")
|
RETURN_TYPES = ("IMAGE", "IMAGE", "INT")
|
||||||
RETURN_NAMES = ("mask", "control_frames", "frames_to_generate")
|
RETURN_NAMES = ("control_frames", "mask", "frames_to_generate")
|
||||||
OUTPUT_TOOLTIPS = (
|
OUTPUT_TOOLTIPS = (
|
||||||
"Mask sequence — black (0) = keep original, white (1) = generate. Per-frame for most modes; per-pixel for Video Inpaint.",
|
|
||||||
"Visual reference for VACE — source pixels where mask is black, grey (#7f7f7f) fill where mask is white.",
|
"Visual reference for VACE — source pixels where mask is black, grey (#7f7f7f) fill where mask is white.",
|
||||||
|
"Mask sequence — black (0) = keep original, white (1) = generate. Per-frame for most modes; per-pixel for Video Inpaint.",
|
||||||
"Number of new frames to generate (white/grey frames added).",
|
"Number of new frames to generate (white/grey frames added).",
|
||||||
)
|
)
|
||||||
DESCRIPTION = """VACE Mask Generator — builds mask + control_frames sequences for all VACE generation modes.
|
DESCRIPTION = """VACE Mask Generator — builds mask + control_frames sequences for all VACE generation modes.
|
||||||
@@ -141,7 +141,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
frames_to_generate = target_frames - B
|
frames_to_generate = target_frames - B
|
||||||
mask = torch.cat([solid(B, BLACK), solid(frames_to_generate, WHITE)], dim=0)
|
mask = torch.cat([solid(B, BLACK), solid(frames_to_generate, WHITE)], dim=0)
|
||||||
control_frames = torch.cat([source_clip, solid(frames_to_generate, GREY)], dim=0)
|
control_frames = torch.cat([source_clip, solid(frames_to_generate, GREY)], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Pre Extend":
|
elif mode == "Pre Extend":
|
||||||
image_a = source_clip[:split_index]
|
image_a = source_clip[:split_index]
|
||||||
@@ -149,7 +149,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
frames_to_generate = target_frames - a_count
|
frames_to_generate = target_frames - a_count
|
||||||
mask = torch.cat([solid(frames_to_generate, WHITE), solid(a_count, BLACK)], dim=0)
|
mask = torch.cat([solid(frames_to_generate, WHITE), solid(a_count, BLACK)], dim=0)
|
||||||
control_frames = torch.cat([solid(frames_to_generate, GREY), image_a], dim=0)
|
control_frames = torch.cat([solid(frames_to_generate, GREY), image_a], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Middle Extend":
|
elif mode == "Middle Extend":
|
||||||
image_a = source_clip[:split_index]
|
image_a = source_clip[:split_index]
|
||||||
@@ -159,7 +159,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
frames_to_generate = target_frames - (a_count + b_count)
|
frames_to_generate = target_frames - (a_count + b_count)
|
||||||
mask = torch.cat([solid(a_count, BLACK), solid(frames_to_generate, WHITE), solid(b_count, BLACK)], dim=0)
|
mask = torch.cat([solid(a_count, BLACK), solid(frames_to_generate, WHITE), solid(b_count, BLACK)], dim=0)
|
||||||
control_frames = torch.cat([image_a, solid(frames_to_generate, GREY), image_b], dim=0)
|
control_frames = torch.cat([image_a, solid(frames_to_generate, GREY), image_b], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Edge Extend":
|
elif mode == "Edge Extend":
|
||||||
start_seg = source_clip[:edge_frames]
|
start_seg = source_clip[:edge_frames]
|
||||||
@@ -169,7 +169,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
frames_to_generate = target_frames - (start_count + end_count)
|
frames_to_generate = target_frames - (start_count + end_count)
|
||||||
mask = torch.cat([solid(end_count, BLACK), solid(frames_to_generate, WHITE), solid(start_count, BLACK)], dim=0)
|
mask = torch.cat([solid(end_count, BLACK), solid(frames_to_generate, WHITE), solid(start_count, BLACK)], dim=0)
|
||||||
control_frames = torch.cat([end_seg, solid(frames_to_generate, GREY), start_seg], dim=0)
|
control_frames = torch.cat([end_seg, solid(frames_to_generate, GREY), start_seg], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Join Extend":
|
elif mode == "Join Extend":
|
||||||
half = B // 2
|
half = B // 2
|
||||||
@@ -182,7 +182,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
frames_to_generate = target_frames - (p2_count + p3_count)
|
frames_to_generate = target_frames - (p2_count + p3_count)
|
||||||
mask = torch.cat([solid(p2_count, BLACK), solid(frames_to_generate, WHITE), solid(p3_count, BLACK)], dim=0)
|
mask = torch.cat([solid(p2_count, BLACK), solid(frames_to_generate, WHITE), solid(p3_count, BLACK)], dim=0)
|
||||||
control_frames = torch.cat([part_2, solid(frames_to_generate, GREY), part_3], dim=0)
|
control_frames = torch.cat([part_2, solid(frames_to_generate, GREY), part_3], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Bidirectional Extend":
|
elif mode == "Bidirectional Extend":
|
||||||
frames_to_generate = max(0, target_frames - B)
|
frames_to_generate = max(0, target_frames - B)
|
||||||
@@ -193,7 +193,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
post_count = frames_to_generate - pre_count
|
post_count = frames_to_generate - pre_count
|
||||||
mask = torch.cat([solid(pre_count, WHITE), solid(B, BLACK), solid(post_count, WHITE)], dim=0)
|
mask = torch.cat([solid(pre_count, WHITE), solid(B, BLACK), solid(post_count, WHITE)], dim=0)
|
||||||
control_frames = torch.cat([solid(pre_count, GREY), source_clip, solid(post_count, GREY)], dim=0)
|
control_frames = torch.cat([solid(pre_count, GREY), source_clip, solid(post_count, GREY)], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Frame Interpolation":
|
elif mode == "Frame Interpolation":
|
||||||
step = max(split_index, 1)
|
step = max(split_index, 1)
|
||||||
@@ -208,7 +208,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
ctrl_parts.append(solid(step, GREY))
|
ctrl_parts.append(solid(step, GREY))
|
||||||
mask = torch.cat(mask_parts, dim=0)
|
mask = torch.cat(mask_parts, dim=0)
|
||||||
control_frames = torch.cat(ctrl_parts, dim=0)
|
control_frames = torch.cat(ctrl_parts, dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Replace/Inpaint":
|
elif mode == "Replace/Inpaint":
|
||||||
start = max(0, min(split_index, B))
|
start = max(0, min(split_index, B))
|
||||||
@@ -219,7 +219,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
after = source_clip[end:]
|
after = source_clip[end:]
|
||||||
mask = torch.cat([solid(before.shape[0], BLACK), solid(length, WHITE), solid(after.shape[0], BLACK)], dim=0)
|
mask = torch.cat([solid(before.shape[0], BLACK), solid(length, WHITE), solid(after.shape[0], BLACK)], dim=0)
|
||||||
control_frames = torch.cat([before, solid(length, GREY), after], dim=0)
|
control_frames = torch.cat([before, solid(length, GREY), after], dim=0)
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Video Inpaint":
|
elif mode == "Video Inpaint":
|
||||||
if inpaint_mask is None:
|
if inpaint_mask is None:
|
||||||
@@ -243,7 +243,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
grey = torch.full_like(source_clip, GREY)
|
grey = torch.full_like(source_clip, GREY)
|
||||||
control_frames = source_clip * (1.0 - m3) + grey * m3
|
control_frames = source_clip * (1.0 - m3) + grey * m3
|
||||||
frames_to_generate = B
|
frames_to_generate = B
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
elif mode == "Keyframe":
|
elif mode == "Keyframe":
|
||||||
if B > target_frames:
|
if B > target_frames:
|
||||||
@@ -290,7 +290,7 @@ If your source is longer, use VACE Source Prep upstream to trim it first."""
|
|||||||
mask = torch.cat(mask_parts, dim=0)
|
mask = torch.cat(mask_parts, dim=0)
|
||||||
control_frames = torch.cat(ctrl_parts, dim=0)
|
control_frames = torch.cat(ctrl_parts, dim=0)
|
||||||
frames_to_generate = target_frames - B
|
frames_to_generate = target_frames - B
|
||||||
return (mask, control_frames, frames_to_generate)
|
return (control_frames, mask, frames_to_generate)
|
||||||
|
|
||||||
raise ValueError(f"Unknown mode: {mode}")
|
raise ValueError(f"Unknown mode: {mode}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user