cmvr-visual/inference/llm_services/video_edit/temporal.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

44 lines
1.5 KiB
Python

"""Bounded Wan windows with native previous-segment latent conditioning."""
class CarryConditioningMixin:
carried_frame = None
def prepare_prev_segment_cond_latents(self, prev_segment_cond_video=None, **kwargs):
if kwargs.get("start_frame", 0) == 0 and self.carried_frame is not None:
# Preserve native [-1,1] BCTHW conditioning and its I2V first-frame
# mask. This is the same bridge Wan uses between internal segments.
prev_segment_cond_video = self.carried_frame.to(device=kwargs.get("device"))
kwargs["start_frame"] = 1
return super().prepare_prev_segment_cond_latents(
prev_segment_cond_video, **kwargs
)
def pipeline_class():
from diffusers import WanAnimatePipeline
class BoundedWanAnimatePipeline(CarryConditioningMixin, WanAnimatePipeline):
pass
return BoundedWanAnimatePipeline
def generate_windows(count, generate):
if count < 1:
raise ValueError("No source frames")
start = 0
previous = None
while start < count:
end = min(start + 77, count)
frames = generate(start, end, previous)
if len(frames) != end - start:
raise ValueError("Temporal window output frame count mismatch")
skip = 1 if start else 0
for offset in range(skip, len(frames)):
yield start + offset, frames[offset]
previous = frames[-1]
if end == count:
break
start = end - 1