pytorch-SRResNet icon indicating copy to clipboard operation
pytorch-SRResNet copied to clipboard

How to get im_h_y from im_h?

Open yuanshuai220 opened this issue 7 years ago • 3 comments

I want to calculate PSNR on Y channel. I have got im_gt_y and im_b_y through the mat format files.

im_gt_y = sio.loadmat("output/" + opt.image + ".mat")['im_gt']
im_b_y = sio.loadmat("output/" + opt.image + ".mat")['im_b']

im_gt_y = im_gt_y.astype(float)
im_b_y = im_b_y.astype(float)

psnr_bicubic = PSNR(im_gt_y, im_b_y, shave_border=opt.scale)

But I have some trouble in getting im_h_y from im_h

im_h_y = im_h[:,:,0].astype(float)
psnr_predicted = PSNR(im_gt_y, im_h_y, shave_border=opt.scale)

The result was not right. I tried to transform the im_h to YCbCr by Image

im_h_ycbcr = np.array(Image.fromarray(im_h, "RGB").convert("YCbCr"))
im_h_y = im_h_ycbcr[0,:,:]
psnr_predicted = PSNR(im_gt_y, im_h_y, shave_border=opt.scale)

It still doesn't work. Can you give me some advice here.

yuanshuai220 avatar Aug 03 '17 02:08 yuanshuai220

@yuanshuai220 please also load im_h_y from mat file after converting rgb images into ycbcr images in matlab. PIL library cannot give you the best performance in calculating PSNR.

twtygqyy avatar Aug 07 '17 11:08 twtygqyy

@twtygqyy can you provide the Matlab script to test psnr? 😂

MKFMIKU avatar Jan 07 '18 13:01 MKFMIKU

@yuanshuai220 ,Hi,I don't know why it needs so much memory when test and the train is normal. Have you ever had this problem? :: RuntimeError: cuda runtime error (2) : out of memory at /opt/conda/conda-bld/pytorch_1501969512886/work/pytorch-0.1.12/torch/lib/THC/generic/THCStorage.cu:66

HPL123 avatar Dec 10 '18 02:12 HPL123