From 75eddc3da48143d9187dff3049e3a35c926267c4 Mon Sep 17 00:00:00 2001 From: AhmedAhmedEG Date: Fri, 30 Aug 2024 15:29:48 +0300 Subject: [PATCH 1/3] Update inference_video.py --- inference_video.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inference_video.py b/inference_video.py index 4711836..a254c00 100644 --- a/inference_video.py +++ b/inference_video.py @@ -241,7 +241,7 @@ def pad_image(img): if ssim < 0.2: output = [] - for i in range(args.multi - 1): + for i in range(args.multi): output.append(I0) ''' output = [] @@ -253,7 +253,7 @@ def pad_image(img): output.append(torch.from_numpy(np.transpose((cv2.addWeighted(frame[:, :, ::-1], alpha, lastframe[:, :, ::-1], beta, 0)[:, :, ::-1].copy()), (2,0,1))).to(device, non_blocking=True).unsqueeze(0).float() / 255.) ''' else: - output = make_inference(I0, I1, args.multi-1) + output = make_inference(I0, I1, args.multi) if args.montage: write_buffer.put(np.concatenate((lastframe, lastframe), 1)) From 2376f3da823c1524f2bd5b5d4a1a43354d78c4e6 Mon Sep 17 00:00:00 2001 From: AhmedAhmedEG Date: Fri, 30 Aug 2024 15:36:47 +0300 Subject: [PATCH 2/3] Update inference_video.py --- inference_video.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inference_video.py b/inference_video.py index a254c00..118c99d 100644 --- a/inference_video.py +++ b/inference_video.py @@ -108,7 +108,7 @@ def transferAudio(sourceVideo, targetVideo): videoCapture.release() if args.fps is None: fpsNotAssigned = True - args.fps = fps * args.multi + args.fps = fps * (args.multi - 1) else: fpsNotAssigned = False videogen = skvideo.io.vreader(args.video) @@ -241,7 +241,7 @@ def pad_image(img): if ssim < 0.2: output = [] - for i in range(args.multi): + for i in range(args.multi - 1): output.append(I0) ''' output = [] @@ -253,7 +253,7 @@ def pad_image(img): output.append(torch.from_numpy(np.transpose((cv2.addWeighted(frame[:, :, ::-1], alpha, lastframe[:, :, ::-1], beta, 0)[:, :, ::-1].copy()), (2,0,1))).to(device, non_blocking=True).unsqueeze(0).float() / 255.) ''' else: - output = make_inference(I0, I1, args.multi) + output = make_inference(I0, I1, args.multi - 1) if args.montage: write_buffer.put(np.concatenate((lastframe, lastframe), 1)) From 5411567851a9eb2ba0a7861c1ca47196a9dcec87 Mon Sep 17 00:00:00 2001 From: AhmedAhmedEG Date: Sun, 1 Sep 2024 22:32:55 +0300 Subject: [PATCH 3/3] Fixed scale passed as timestep bug --- inference_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference_video.py b/inference_video.py index 118c99d..468b330 100644 --- a/inference_video.py +++ b/inference_video.py @@ -234,7 +234,7 @@ def pad_image(img): temp = frame I1 = torch.from_numpy(np.transpose(frame, (2,0,1))).to(device, non_blocking=True).unsqueeze(0).float() / 255. I1 = pad_image(I1) - I1 = model.inference(I0, I1, args.scale) + I1 = model.inference(I0, I1, scale=args.scale) I1_small = F.interpolate(I1, (32, 32), mode='bilinear', align_corners=False) ssim = ssim_matlab(I0_small[:, :3], I1_small[:, :3]) frame = (I1[0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w]