Grey Image Colorization using deep learning
Afficher commentaires plus anciens
Hello, I'm trying to colorize an grey image using Matlab. there is multiple example in pyhton etc. I can't find any example in mathlab. I'm sharing the codes I got until today.
When training is over I got a little colored images but mostly yelow. And traning progress down below as an image. Can you tell me how can I read this graph? How can I understant it's fail or still learning ?
What should I do ? Some examples using Lab colorstyle instead of RGB. How can I train using Lab?
And I want to learn this codes meanings :
miniBatchSize = 16;
patchSize = [250 250];
patchds = randomPatchExtractionDatastore(greyimds,Trainimds,patchSize, ....
'PatchesPerImage',64);
patchds.MiniBatchSize = miniBatchSize;
When I scale up miniBatchSize my training fail because of GPU. Why?
When I scale up encoderDepth, traning can't work because it's ask for 2*Image height/width or something like that? How can I calculate it ? What it's means?
lgraph = unetLayers([250 250 3] , 3,'encoderDepth',1);
And last question: How can I get score of tranings success rate? I try some codes but they don't let me because it's not a classification problem.
Thanks for everything.

imagesDir = '.';
greyImagesDir = fullfile(imagesDir,'greyImages');
trainImagesDir = fullfile(imagesDir,'trainImages');
exts = {'.jpg','.bmp','.png'};
greyimds = imageDatastore(blurredImagesDir)
Trainimds = imageDatastore(trainImagesDir)
miniBatchSize = 16;
patchSize = [250 250];
patchds = randomPatchExtractionDatastore(greyimds,Trainimds,patchSize, ....
'PatchesPerImage',64);
patchds.MiniBatchSize = miniBatchSize;
lgraph = unetLayers([250 250 3] , 3,'encoderDepth',1);
lgraph = lgraph.removeLayers('Softmax-Layer');
lgraph = lgraph.removeLayers('Segmentation-Layer');
lgraph = lgraph.addLayers(regressionLayer('name','regressionLayer'));
lgraph = lgraph.connectLayers('Final-ConvolutionLayer','regressionLayer');
maxEpochs = 30;
epochIntervals = 1;
initLearningRate = 0.1;
learningRateFactor = 0.1;
l2reg = 0.0001;
options = trainingOptions('sgdm', ...
'Momentum',0.9, ...
'InitialLearnRate',initLearningRate, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',10, ...
'LearnRateDropFactor',learningRateFactor, ...
'L2Regularization',l2reg, ...
'MaxEpochs',maxEpochs ,...
'MiniBatchSize',miniBatchSize, ...
'GradientThresholdMethod','l2norm', ...
'Plots','training-progress', ...
'GradientThreshold',0.01);
modelDateTime = datestr(now,'dd-mmm-yyyy-HH-MM-SS');
net = trainNetwork(patchds,lgraph,options);
save(['trainedNet-' modelDateTime '-Epoch-' num2str(maxEpochs*epochIntervals) ...
'ScaleFactors-' num2str(234) '.mat'],'net','options');
------------------Colorize image using code below---
Idegray = activations(net,testimage,'regressionLayer');
figure; imshow(Idegrey)
Iapprox = rescale(Idegrey);
Iapprox = im2uint8(Iapprox);
imshow(Iapprox)
title('Colored Image')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Deep Learning for Image Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!