Open star4s opened 7 years ago
@star4s
Do you change any training code?
The result seems like only show the green channel.
I did not change your code. I just use your code on the page. What's the problem? I did not know the situation.
@star4s There may be several things you need to check:
Do you show the result in a right way? Does the third channel of the output equal to 3? (for example 224x224x3)
If the scale of the image are in the range 1 to 256, the format of the img should be 'uint8'. uint8(img)
If the image are in the range 0 to 1, it should be 'single'. single(img)
Visualize the training images you downloaded. Are they right?
Yes, the result of the image is 656 988 3 single.
This is your the training images.
This is a result graph after I train from your images.
When I compared your result graph, the result is very different.
Do you use %im_1 = rgb2ycbcr(im_1);
?
Actually I do not use it and comment it.
I tried again by using same option for training images.
I have different color result.
I do not know why the result is strange.
This is my code from your code train_SRnet.m could you check what the problem is?
function train_SRnet(varargin) addpath('C:\Program Files\MATLAB'); % ------------------------------------------------------------------------- % Part 4.1: prepare the data % -------------------------------------------------------------------------
% Load character dataset imdb = load('./2014_data_url_onlycolor.mat') ; imdb = imdb.imdb; imdb.meta.sets=['train','val']; ss = size(imdb.images.data); imdb.images.set = ones(1,ss(2)); imdb.images.set(ceil(rand(1,ceil(ss(2)/20))*ss(2))) = 2; % ------------------------------------------------------------------------- % Part 4.2: initialize a CNN architecture % -------------------------------------------------------------------------
net = SRnet(); net.conserveMemory = true; %net = load('data/48net-cifar-v3-custom-dither0.1-128-3hard/f48net-cpu.mat');
% ------------------------------------------------------------------------- % Part 4.3: train and evaluate the CNN % -------------------------------------------------------------------------
opts.train.batchSize = 128; %opts.train.numSubBatches = 1 ; opts.train.continue = true; opts.train.gpus = 1; opts.train.prefetch = false ; %opts.train.sync = false ; %opts.train.errorFunction = 'multiclass' ; opts.train.expDir = './data/SRnet-v1-color-128_new'; opts.train.learningRate = [1e-5ones(1,3) 1e-6ones(1,1)]; opts.train.weightDecay = 0.0005; opts.train.numEpochs = numel(opts.train.learningRate) ; opts.train.derOutputs = {'objective',1} ; [opts, ~] = vl_argparse(opts.train, varargin) ;
%record if(~isdir(opts.expDir)) mkdir(opts.expDir); copyfile('SRnet.m',opts.expDir); end
% Call training function in MatConvNet [net,info] = cnn_train_daga(net, imdb, @getBatch,opts) ;
% -------------------------------------------------------------------- function inputs = getBatch(imdb, batch,opts) % -------------------------------------------------------------------- imlist = imdb.images.data(:,batch) ; batch_size = numel(batch); img = zeros(128,128,3,batch_size,'single'); training = opts.learningRate>0; for i=1:batch_size p1 = imlist{i}; im_1 = imread(p1); %im_1 = rgb2ycbcr(im_1); %im_1 = rgb2gray(im_1);
im_1 = im2single(im_1);
im_1 = single(random_cut128(im_1));
img(:,:,:,i) = im_1;
end if(rand>0.5) img = fliplr(img); end label = img(7:end-6,7:end-6,:,:); [w,h,~,~] = size(img); r = 2 + 2*rand; input = imresize(imresize(img,1/r),[w,h]); inputs = {'input',gpuArray(input),'label',gpuArray(label)};
If you look at my code, train_SRnet.m, I did not use %im_1 = rgb2ycbcr(im_1); and %im_1 = rgb2gray(im_1); . I just input train_SRnet on the command line of the matlab.
add imshow(input(:,:,:,1));
before the inputs = {'input',gpuArray(input),'label',gpuArray(label)};
add breakpoint.
Does it show right?
After I add breakpoint, there is the result.
And then, the result on the command line,
there is text.
I think the input is right. The question may be in the training process.
The training curve do not converge?? The loss seems keep high.
Do you use my initial code? /matlab/+dagnn/@DagNN/initParam.m
What's mean? The curve do not converge?? I just used your code in the training process. I changed the option for count of the GPU. on your code, there is opts.train.gpus = 2; My gpu is 1. so I changed the option by 1. Like that, opts.train.gpus = 1;
And I did not changed your code.
my vl_compilenn 's option is just vl_compilenn('enableGpu', true); and then I can use GPU and Caffe.
I did not use initial code, /matlab/+dagnn/@DagNN/initParam.m How can I run the initial code? My processing was
I wrote this code one year ago and do not keep it in my computer. Let me download file and re-train my model to see whether there is any bugs. It may take some times. But I will try and tell you the result.
Thank you very much for your using time.
@star4s I found the bugs.
getBatch
function.So I will upload a fixed version for training code today. And I will remove some unnecessary files to keep it more clear and simply to train.
Hello. I have a problem after I trained your sample images, which you did upload in baidu. And I apply the mat file in your testSRnet_result.m after the training and, I also apply the mat file, your 2014_data_url_onlycolor.mat. After I run the testSRnet_result.m, I got the strange result like the bottom. left: original image , right: SR image![1](https://cloud.githubusercontent.com/assets/25783167/25507722/de684184-2be8-11e7-9f51-f0bca2fabba1.jpg)
However, when I apply your mat file for the training, it works well. I think I got the problem in my image training. Thank you for your attention.