sanghyun-son / EDSR-PyTorch

PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)
MIT License
2.43k stars 669 forks source link

PSNR calculation on benchmark datasets incorrectly uses all 3 channels of YCbCr #85

Closed ptkin closed 5 years ago

ptkin commented 5 years ago

Hello, thank you very much for sharing the code!

But I have a question.Both the paper and README.md mentioned that when evaluating on benchmark datasets, the PSNR calculation is only done in the Y channel of YCbCr space, but I found that the calculation of PSNR is actually performed on all the three channels of YCbCr by calling sum method (https://github.com/thstkdgus35/EDSR-PyTorch/blob/master/src/utility.py#L174). In my opinion, if evaluation is only done on the Y channel, then this line diff = diff.mul(convert).sum(dim=1) should be changed to diff = diff.mul(convert)[:, 0, :, :].

I am wondering if there is something wrong with my understanding, or the method or description are not corresponding? Looking forward to your reply.

sanghyun-son commented 5 years ago

Hello.

Our code does not calculate Cb or Cr channel.

gray_coeffs only contain numbers that are related to calculate the Y channel.

Please refer the following equations.

y_sr = 16 + (65.738 * sr[:, 0, :, :] + 129.057 * sr[:, 1, :, :] + 25.064 * sr[:, 2, :, :]) / 256 y_hr = 16 + (65.738 * hr[:, 0, :, :] + 129.057 * hr[:, 1, :, :] + 25.064 * hr[:, 2, :, :]) / 256 y_diff = (65.738 * (sr - hr)[:, 0, :, :] + 129.057 * (sr - hr)[:, 1, :, :] + 25.064 * (sr - hr)[:, 2, :, :]) / 256 since diff = (sr - hr) / rgb_range, y_diff = diff.mul(convert).sum(dim=1) (lies in between 0 and 1)

Thank you!

ptkin commented 5 years ago

Oh yes, I have made a mistake, thank you for the reply!