model.eval() model.device() path = 'UCF101/ucf101_interp_ours/' dirs = os.listdir(path) psnr_list = [] ssim_list = [] print(len(dirs)) for d in dirs: img0 = (path + d + '/frame_00.png') img1 = (path + d + '/frame_02.png') gt = (path + d + '/frame_01_gt.png') img0 = (torch.tensor(cv2.imread(img0).transpose(2, 0, 1) / 255.)).to(device).float().unsqueeze(0) img1 = (torch.tensor(cv2.imread(img1).transpose(2, 0, 1) / 255.)).to(device).float().unsqueeze(0) gt = (torch.tensor(cv2.imread(gt).transpose(2, 0, 1) / 255.)).to(device).float().unsqueeze(0) pred = model.inference(img0, img1)[0] ssim = ssim_matlab(gt, torch.round(pred * 255).unsqueeze(0) / 255.).detach().cpu().numpy() out = pred.detach().cpu().numpy().transpose(1, 2, 0) out = np.round(out * 255) / 255. gt = gt[0].cpu().numpy().transpose(1, 2, 0) psnr = -10 * math.log10(((gt - out) * (gt - out)).mean()) psnr_list.append(psnr) ssim_list.append(ssim) print("Avg PSNR: {} SSIM: {}".format(np.mean(psnr_list), np.mean(ssim_list)))
model = Model() model.load_model('./train_log') model.eval() model.device() path = 'vimeo_interp_test/' f = open(path + 'tri_testlist.txt', 'r') psnr_list = [] ssim_list = [] for i in f: name = str(i).strip() if (len(name) <= 1): continue print(path + 'target/' + name + '/im1.png') I0 = cv2.imread(path + 'target/' + name + '/im1.png') I1 = cv2.imread(path + 'target/' + name + '/im2.png') I2 = cv2.imread(path + 'target/' + name + '/im3.png') I0 = (torch.tensor(I0.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0) I2 = (torch.tensor(I2.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0) mid = model.inference(I0, I2)[0] ssim = ssim_matlab( torch.tensor(I1.transpose(2, 0, 1)).to(device).unsqueeze(0) / 255., mid.unsqueeze(0)).cpu().numpy() mid = np.round( (mid * 255).cpu().numpy()).astype('uint8').transpose(1, 2, 0) / 255. I1 = I1 / 255. psnr = -10 * math.log10(((I1 - mid) * (I1 - mid)).mean()) psnr_list.append(psnr) ssim_list.append(ssim) print(np.mean(psnr_list), np.mean(ssim_list))
model.eval() model.device() path = 'vimeo_interp_test/' f = open(path + 'tri_testlist.txt', 'r') psnr_list = [] ssim_list = [] for i in f: name = str(i).strip() if (len(name) <= 1): continue print(path + 'target/' + name + '/im1.png') I0 = cv2.imread(path + 'target/' + name + '/im1.png') I1 = cv2.imread(path + 'target/' + name + '/im2.png') I2 = cv2.imread(path + 'target/' + name + '/im3.png') I0 = (torch.tensor(I0.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0) I2 = (torch.tensor(I2.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0) mid = model.inference(I0, I2)[0] ssim = ssim_matlab( torch.tensor(I1.transpose(2, 0, 1)).to(device).unsqueeze(0) / 255., torch.round(mid * 255).unsqueeze(0) / 255.).detach().cpu().numpy() mid = np.round( (mid * 255).detach().cpu().numpy()).astype('uint8').transpose(1, 2, 0) / 255. I1 = I1 / 255. psnr = -10 * math.log10(((I1 - mid) * (I1 - mid)).mean()) psnr_list.append(psnr) ssim_list.append(ssim) print("Avg PSNR: {} SSIM: {}".format(np.mean(psnr_list), np.mean(ssim_list)))