CodeFormer
CodeFormer copied to clipboard
About calculating PSNR and SSIM metrics
Hi, thanks for your great work. I'm reproducting your work and have recovered visually amazing results. However, I find the results of the two metrics PSNR and SSIM not aligned with those in your paper. I'm a newer in blind face restoration task and I can't find the reason about it. Here is the code of my calculation:
def calculate_psnr(img1, img2):
assert img1.shape == img2.shape, (f'Image shapes are differnet: {img1.shape}, {img2.shape}.')
img1 = img1.astype(np.float64)
img2 = img2.astype(np.float64)
mse = np.mean((img1 - img2)**2)
if mse == 0:
return float('inf')
return 10. * np.log10(255.*255.0 /mse)
which is completely the same with your metric codes and so do SSIM. I send the saved results and the corresponding groundtruth to the function. But my results on CelebA-test is about 5 point higher than your PSNR and 0.2 higher than your SSIM. Can you help me with my problems?