pytorch-LapSRN
pytorch-LapSRN copied to clipboard
SSIM calculation
Hi, We are trying to train and test the LapSRN pytorch code provided by you. I would like to if there is any standard implementation of SSIM. Also its not clear how to give the two inputs to SSIM implementation from skimage. Should it be in uint8 (0 to 255)?
Thank You.
Hi @sriprabhar you can use the skimage for SSIM calculation, the two inputs should be in grey scale and in uint8 format. (You can check this article for more details)
Thanks a lot for your reply. We have trained the LapSRN using Div2k dataset. For training we have used your matlab and python code. We want to get the PSNR and SSIM numbers reported in the paper for Set5, Set14, Urban100 etc. There are some parts of the matlab test code and python test code which needs more understanding.
-
Matlab test code ============= im_gt_ycbcr = rgb2ycbcr(im_gt / 255.0); im_gt_y = im_gt_ycbcr(:,:,1) * 255.0; im_l_ycbcr = imresize(im_gt_ycbcr, 1/scale, 'bicubic'); im_b_ycbcr = imresize(im_l_ycbcr, scale, 'bicubic'); im_l_y = im_l_ycbcr(:,:,1) * 255.0; im_l_cb = im_l_ycbcr(:,:,2) * 255.0; im_l_cr = im_l_ycbcr(:,:,3) * 255.0; im_l = ycbcr2rgb(im_l_ycbcr) * 255.0; im_b_y = im_b_ycbcr(:,:,1) * 255.0 im_b_cb = im_b_ycbcr(:,:,2) * 255.0; im_b_cr = im_b_ycbcr(:,:,3) * 255.0; im_b = ycbcr2rgb(im_b_ycbcr) * 255.0; save(filename, 'im_gt_y', 'im_b_y', 'im_gt', 'im_b', 'im_l_ycbcr', 'im_l_y', 'im_l', 'im_b_cb', 'im_b_cr','im_gt_gray','im_b_gray');
-
Python test code ============= im_h_y is the predicted 4x output of LapSRN
im_h_y = im_h_y*255. im_h_y[im_h_y<0] = 0 im_h_y[im_h_y>255.] = 255. im_h_y = im_h_y[0,:,:]
That is, in matlab code we are taking im_gt_y which is a double value from 0 to 255. In python we are taking the output of the network, multiplying it by 255 and clipping to range 0 to 255. This modified im_h_y is a float32 value.
Now to get the PSNR and SSIM values closer to the paper, which pair of values should we take to compute PSNR and SSIM. For PSNR we are taking im_gt_y from matlab as ground truth and im_h_y as predicted output. This value gives considerable difference between ours and what is given in the paper. Similar difficulty we are facing for SSIM measure. Please let us know how your views/suggestions to handle this problem.
Hi @sriprabhar, how much difference did you get from the model you trained and the performance on the paper? Did you try to reproduce the result in my repo?
Hi, PSNR obtained with Div2k training on LapSRN is around 0.3 dB greater than that given in paper. We used the test.py code after following your post in https://github.com/twtygqyy/pytorch-vdsr/issues/4 For SSIM we are getting around 0.1 decrease than that given in paper.
Hi @sriprabhar thanks for the update. 0.3 dB PSNR improvement looks promising, good job. For the SSIM, I guess there is still some different from Matlab implementation with the one python. Personally I'm using the same code as you are using for the calculation.