Closed alterzero closed 5 years ago
Hi @alterzero Did you get the same value as the report? I can not get the same value (MEME-Net*) by using bose python or matlab.
I changed the python code from https://github.com/baowenbo/MEMC-Net/blob/master/demo_HD720p.py .
I also save the gth png and the result png, then use the matlab. Is it right?
Reader = YUV_Read(input_file, hh, ww, toRGB=True)
Reader_res = YUV_Read(gen_file, hh, ww, toRGB=True)
for index in range(0, 100, 2): # len(files) - 2, 2):
gt_rgb, sucess = Reader.read(index + 1)
rec_rgb, sucess_res = Reader_res.read(index + 1)
if not sucess or not sucess_res:
break
if not os.path.exists(os.path.join(outdir, 'gt', file_i[:-4])):
os.makedirs(os.path.join(outdir, 'gt', file_i[:-4]))
if not os.path.exists(os.path.join(outdir, 'res', file_i[:-4])):
os.makedirs(os.path.join(outdir, 'res', file_i[:-4]))
imsave(os.path.join(outdir, 'gt', file_i[:-4], str(index + 1) + '.png'), gt_rgb)
imsave(os.path.join(outdir, 'res', file_i[:-4], str(index + 1) + '.png'), rec_rgb)
gt_yuv = rgb2yuv(gt_rgb / 255.0)
rec_yuv = rgb2yuv(rec_rgb / 255.0)
gt_rgb = gt_yuv[:, :, 0] * 255.0
rec_rgb = rec_yuv[:, :, 0] * 255.0
gt_rgb = gt_rgb.astype('uint8')
rec_rgb = rec_rgb.astype('uint8')
diff_rgb = 128.0 + rec_rgb - gt_rgb
avg_interp_error_abs = np.mean(np.abs(diff_rgb - 128.0))
interp_error.update(avg_interp_error_abs,1)
mse = numpy.mean((diff_rgb - 128.0) ** 2)
if mse == 0:
return 100.0
PIXEL_MAX = 255.0
psnr = 20 * math.log10(PIXEL_MAX / math.sqrt(mse))
psnr_error.update(psnr, 1)
ssim = compare_ssim(rec_rgb, gt_rgb,multichannel=False)
ssim_error.update(ssim,1)
diff_rgb = diff_rgb.astype("uint8")
print("interpolation error / PSNR : " + str(round(avg_interp_error_abs,4)) + " ,\t psnr " + str(round(psnr,4))+ ",\t ssim " + str(round(ssim,5)))
fh = open(os.path.join(outdir, file_i[:-4] + "_psnr_Y.txt"), "a+")
fh.write(str(psnr))
fh.write("\n")
fh.close()
fh = open(os.path.join(outdir, file_i[:-4] + "_ssim_Y.txt"), "a+")
fh.write(str(ssim))
fh.write("\n")
fh.close()
metrics = "The average interpolation error / PSNR for all images are : " + str(
round(interp_error.avg, 4)) + ",\t psnr " + str(round(psnr_error.avg, 4)) + ",\t ssim " + str(
round(ssim_error.avg, 4))
print(metrics)
metrics = "The average interpolation error / PSNR for all images are : " + str(round(interp_error.avg,4)) + ",\t psnr " + str(round(psnr_error.avg,4)) + ",\t ssim " + str(round(ssim_error.avg,4))
print(metrics)
fh = open(os.path.join(outdir, file_i[:-4] + "_psnr_Y.txt"), "a+")
fh.write("\n")
fh.write(str(psnr_error.avg))
fh.write("\n")
fh.close()
fh = open(os.path.join(outdir, file_i[:-4] + "_ssim_Y.txt"), "a+")
fh.write("\n")
fh.write(str(ssim_error.avg))
fh.write("\n")
fh.close()
res_psnr.append(psnr_error.avg)
res_ssim.append(ssim_error.avg)
return res_psnr, res_ssim
Hi, nice work! Can you share the GT of HD dataset? I try look for it, unfortunately I cannot find it. Thanks!