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

关于测试的困惑

Open JYP2011 opened this issue 6 years ago • 6 comments

Hi, 对于下面的代码片段比较困惑,为什么在将rgb图片转换为ycbcr时要先除以255,最后为了得到y通道还要乘以255呢? 我不明白这有什么意义,按照矩阵运算,除以255然后乘以255.应该没差别才对。 但是事实是,您的做法似乎保证了非负。 打扰了。

clear;close all;
%% settings
folder = 'Set5';

%% generate data
filepaths = [];
filepaths = [filepaths; dir(fullfile(folder, '*.bmp'))];

scale = [2, 3, 4];

for i = 1 : length(filepaths)
    im_gt = imread(fullfile(folder,filepaths(i).name));
    for s = 1 : length(scale) 
        im_gt = modcrop(im_gt, scale(s));
        im_gt = double(im_gt);
        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(s),'bicubic');
        im_b_ycbcr = imresize(im_l_ycbcr,scale(s),'bicubic');
        im_l_y = im_l_ycbcr(:,:,1) * 255.0;
        im_l = ycbcr2rgb(im_l_ycbcr) * 255.0;
        im_b_y = im_b_ycbcr(:,:,1) * 255.0;
        im_b = ycbcr2rgb(im_b_ycbcr) * 255.0;
        last = length(filepaths(i).name)-4;
        filename = sprintf('Set5_mat/%s_x%s.mat',filepaths(i).name(1 : last),num2str(scale(s)));
        save(filename, 'im_gt_y', 'im_b_y', 'im_gt', 'im_b', 'im_l_ycbcr', 'im_l_y', 'im_l');
    end
end

JYP2011 avatar Oct 11 '18 13:10 JYP2011

Hi, for rgb2ycbcr function in Matlab, if the input is uint8 (0~255), YCBCR will be uint8, while if the input is a double, YCBCR will be double. The 255.0 division is just for 0,1 normalization, you can do without it.

twtygqyy avatar Oct 11 '18 21:10 twtygqyy

Hi, for rgb2ycbcr function in Matlab, if the input is uint8 (0~255), YCBCR will be uint8, while if the input is a double, YCBCR will be double. The 255.0 division is just for 0,1 normalization, you can do without it.

可是作normalization和不作nomalization的得到结果不一样呀,我做过测试,相差很多。

JYP2011 avatar Oct 12 '18 11:10 JYP2011

训练的时候input的数据必须是normalized,范围是0~1 不然输入的distribution差别太大

twtygqyy avatar Oct 12 '18 16:10 twtygqyy

@JYP2011 @twtygqyy In your experience, which is better for nomalization and non-nomalization?

The input requirement to be nomalized into 0~1 probably might be relaxed by adding a batchnorm layer.

blueardour avatar Apr 30 '19 07:04 blueardour

For super-resolution problem, batch_norm is not recommended because it normalizes the intensity level across samples in each batch.

twtygqyy avatar May 03 '19 20:05 twtygqyy

hi,Why did I encounter this problem? May I ask how did you do it in the test? I have consulted some solutions, but they are still useless. UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 918: ordinal not in range(128)

Missdonghui avatar Jul 11 '19 08:07 Missdonghui