fix(video): normalize pixel range to [0,1] before RIFE

video_save passes [-1,1]-range pixels to rife.interpolate_nchw, but
RIFE v4.25's IFNet explicitly clamps inputs to [0,1] (Head and IFNet
forward pass), turning every negative pixel value into zero. v3.9
silently extrapolated and produced soft artifacts; v4.25 produces
washout. Convert to [0,1] before the RIFE call and back to [-1,1] for
downstream save.
This commit is contained in:
CalamitousFelicitousness
2026-04-25 21:14:36 +01:00
parent dc4c58d0cb
commit 121b357ba0
+2
View File
@@ -273,9 +273,11 @@ def save_video(
stream.output_queue.push(('progress', (None, 'Saving video...')))
if mp4_interpolate > 0:
x = pixels.squeeze(0).permute(1, 0, 2, 3)
x = (x.clamp(-1., 1.) + 1.0) * 0.5 # RIFE expects [0, 1]; video pixels are [-1, 1]
interpolated = rife.interpolate_nchw(x, count=mp4_interpolate+1)
pixels = torch.stack(interpolated, dim=0)
pixels = pixels.permute(1, 2, 0, 3, 4)
pixels = pixels * 2.0 - 1.0 # back to [-1, 1] for downstream save
n, _c, t, h, w = pixels.shape
x = torch.clamp(pixels.float(), -1., 1.) * 127.5 + 127.5