Creating a convolutional neural network that outputs an image.
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am in the process of implementing a convolutional neural network for image denoising. The network architecture was proposed in THIS paper, on page 4. I am using Matlab 2018b, so I have all the latest Deep learning toolboxes installed. I have tried to recreate the neural network in the Deep Network Designer app, as can be seen in the two first images attached. The network analyzer shows no errors or warning, and the dimensions are ok.
Then I created an imagedatastore with my images. The second step was creating an denoisingImageDatastore for the sake of training deep networks. I then set the training options, and eventually went to train my network. All these steps were show in Mathworks tutorials, but here is the code anyway.
DatasetPath=fullfile('c:\', 'Users', 'Emir', 'Desktop', 'IU','seminarski', 'VOCdevkit', 'VOC2010','JPEGImagesSmall');
imds=imageDatastore(DatasetPath, 'IncludeSubfolders', true,...
'LabelSource','foldernames');
%% denoising image data set
dnimds=denoisingImageDatastore(imds,'patchSize', [64 64], 'PatchesPerImage', 64, 'ChannelFormat','grayscale');
%%
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',1, ...
'Shuffle','every-epoch', ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress',...
'ExecutionEnvironment', 'gpu');
%%
net=trainNetwork(dnimds, lgraph_8,options); %% lgraph_8 is the name of the network returned by the deep network designer app
I then went to test my trained network on the cameraman image.
I=imread('cameraman.tif');
noisyI=imnoise(I, 'gaussian', 0,0.01);
figure
imshowpair(I, noisyI, 'montage');
title('Original Image (left) and Noisy Image (right)')
%%
denoisedI=denoiseImage(noisyI,net);
figure
imshow(denoisedI)
title('Denoised Image')
I get the following error message when running this script.
"Name of layer output must be a character vector or string scalar.
Error in DAGNetwork/activations (line 815)
iValidateIsStringOrCharArray(layerOut);
Error in denoiseImage (line 73)
res = activations(net,inputImage,numLayers-1,'OutputAs','channels');
Error in Untitled (line 44)
denoisedI=denoiseImage(noisyI,net);"
What causes this error message? In the proposed network, the output is an image of the dimensions 64x64x1, however it seems that matlab only lets me use the classification and regression output layers. How do I overcome this. I analyzed the structure of this network, and it is quite similar to mine, but the code which gave me an error previously runs fine when I use that pretrained network. What changes can I make to my network so it doesn't give me these errors?
0 commentaires
Réponse acceptée
Joss Knight
le 2 Fév 2019
You have a DAGNetwork which means you cannot pass a layer index into activations, you have to pass a name:
res = activations(net,inputImage,net.Layers(numLayers-1).Name,'OutputAs','channels');
4 commentaires
Joss Knight
le 2 Fév 2019
You should ask another question, because your question is now concerned with domain knowledge in Deep Learning and Computer Vision, rather than just MATLAB syntax, for which there are other, much more appropriate people to help!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Deep Learning for Image Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!