Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not reappear the PSNR and SSIM result for version3 #8

Closed
selous123 opened this issue Sep 18, 2019 · 2 comments
Closed

Can not reappear the PSNR and SSIM result for version3 #8

selous123 opened this issue Sep 18, 2019 · 2 comments

Comments

@selous123
Copy link

I have downloaded your matlab code and run below code which modified from your test.m

clear; clc; close all; warning off;
addpath(genpath('./.'));
scale      = 4;
count = 1;
for q = 1:2
    folder2   =  ['/store/dataset/RealSR/All/Test/4'];
    filepathsHR =  [];
    filepathsHR = cat(1,filepathsHR, dir(fullfile(folder2, 'HR', '*.png')));
    
    for i = 1 : 2: length(filepathsHR)
        % disp(i)
        HR = imread(fullfile(folder2,'HR',filepathsHR(i).name));
        HR = modcrop(HR, scale);
        HR_Ycbcr = im2double(rgb2ycbcr(HR));
        HR_Y = im2single(HR_Ycbcr(:, :, 1));
        
        LR = imread(fullfile(folder2,'LR',filepathsHR(i).name));
        LR = imresize(LR , scale, 'bicubic');
        LR = modcrop(LR, scale);
        LR_Ycbcr = im2double(rgb2ycbcr(LR));
        LR_Y = im2single(LR_Ycbcr(:, :, 1));
        
        % The testing image is too large and will cause out-of-memory issue.
        size_img = size(LR_Y);           
        if ((size_img(1) > 1200) && (size_img(2) > 1200))
            size_patch = [1200 1200];
            size_skip = [800 800];
            [patch] = im2patch(LR_Y, size_patch, size_skip);
            [patchY] = im2patch(HR_Y, size_patch, size_skip);
        else
            patch = LR_Y;
            patchY = HR_Y;
        end
        
        
%         for k = 1:size(patch,3)
%             [PSNRCur, SSIMCur] = Cal_PSNRSSIM(im2uint8(patchY(:,:,k)),im2uint8(patch(:,:,k)),0,0);
%             PSNRs(count) = PSNRCur;
%             SSIMs(count) = SSIMCur;
%             PSNRs(count)
%             SSIMs(count)
%             count = count + 1;
%         end
         [PSNRCur, SSIMCur] = Cal_PSNRSSIM(im2uint8(patchY(:,:,1)),im2uint8(patch(:,:,1)),0,0);
         PSNRs(count) = PSNRCur;
         SSIMs(count) = SSIMCur;
         PSNRs(count)
         SSIMs(count)
         count = count + 1;
    end
end
length(PSNRs)
mean(PSNRs)
mean(SSIMs)

but the result for Bicubic baseline is PSNR:26.8944 SSIM:0.7570, which is different from what you reported here
so any details i have not noticed?

Hope for your replying!!
Thanks.

@csjcai
Copy link
Owner

csjcai commented Sep 18, 2019

@selous123 Hi, for images in Version 3, we do not divide images into patches since the network itself requires less memory than Version 2 (the input LR has the same resolution as HR). You can just run them in the original size.
Also, since in Version 3, LR and HR have different size, you need to bicubic upsample the LR then calculate the PSNR and SSIM. You should also remove the function 'modcrop' here.

The provided files (models, train and test codes) are designed for Version 2.

@selous123
Copy link
Author

Thank you very much for answering.
I have corrected my code according to your suggestions.

And I have got the result PSNR: 27.2291 and SSIM: 0.7627, which is slightly different from the reported values, PSNR: 27.2378 and SSIM: 0.7643.

I have also touched my code below for others.

clear; clc; close all; warning off;
addpath(genpath('./.'));
scale      = 4;

count = 1;

folder2   =  ['/store/dataset/RealSR/All/Test/4'];
filepathsHR =  [];
filepathsHR = cat(1,filepathsHR, dir(fullfile(folder2, 'HR', '*.png')));

for i = 1 : 1: length(filepathsHR)
    disp(i)
    HR = imread(fullfile(folder2,'HR',filepathsHR(i).name));
    %HR = modcrop(HR, scale);
    HR_Ycbcr = im2double(rgb2ycbcr(HR));
    HR_Y = im2single(HR_Ycbcr(:, :, 1));

    LR = imread(fullfile(folder2,'LR',filepathsHR(i).name));
    LR = imresize(LR , scale, 'bicubic');
    %LR = modcrop(LR, scale);
    LR_Ycbcr = im2double(rgb2ycbcr(LR));
    LR_Y = im2single(LR_Ycbcr(:, :, 1));

    % The testing image is too large and will cause out-of-memory issue.
    assert(isempty(setdiff(size(LR_Y), size(HR_Y))))

    [PSNRCur, SSIMCur] = Cal_PSNRSSIM(im2uint8(HR_Y),im2uint8(LR_Y),0,0);
    PSNRs(count) = PSNRCur;
    SSIMs(count) = SSIMCur;
    count = count + 1;
end

length(PSNRs)
mean(PSNRs)
mean(SSIMs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants