Fix FlashVSR ghosting: restore 2 front dummy frames matching reference

The pipeline's LQ conditioning indexing expects 2 front dummy frames
(copies of first frame) as warmup. Our previous refactoring removed
these, shifting all LQ conditioning by 2 frames and causing severe
ghosting artifacts.

Now matches the 1038lab reference preprocessing exactly:
1. _prepare_video: 2 tail copies + alignment + 2 front dummies + back padding
2. _restore_video_sequence: strip first 2 warmup frames + trim to original count
3. Crop pipeline output to padded_n before restoration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 16:49:46 +01:00
parent 4cc6e9c705
commit ea84ffef7c
2 changed files with 58 additions and 52 deletions

View File

@@ -1731,14 +1731,16 @@ class FlashVSRUpscale:
chunks.append((prev_start, last_end))
# Estimate total pipeline steps for progress bar
# Mirrors _pad_video_5d: pad to num_frames % 8 == 1, min 25
# Mirrors _prepare_video: N+2 tail, align (n-5)%8, then align_frames(padded+4)
total_steps = 0
for cs, ce in chunks:
nf = max(ce - cs, 25)
remainder = (nf - 1) % 8
n = ce - cs
padded = n + 2
remainder = (padded - 5) % 8
if remainder != 0:
nf += 8 - remainder
total_steps += max(1, (nf - 1) // 8 - 2)
padded += 8 - remainder
aligned = FlashVSRModel._align_frames(padded + 4)
total_steps += max(1, (aligned - 1) // 8 - 2)
pbar = ProgressBar(total_steps)
step_ref = [0]