i have a problem with augmentedimagedatastore how can i solve it?
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
matlabroot = 'C:\Users\user a\Desktop\Hind\Image C\data101';
DatasetPath = fullfile(matlabroot);
Data = imageDatastore(DatasetPath,'IncludeSubfolders',true,'LabelSource','foldernames');
CountLabel = Data.countEachLabel;
auds = augmentedImageDatastore([224 224],Data);
trainData1 = auds;
[trainData] = auds;
netWidth = 16;
layers = [
    imageInputLayer([224 224 3],'Name','input') 
    convolution2dLayer(3,netWidth,'Padding','same','Name','convInp')
    batchNormalizationLayer('Name','BNInp')
    reluLayer('Name','reluInp')
    convolutionalUnit(netWidth,1,'S1U1')
    additionLayer(2,'Name','add11')
    reluLayer('Name','relu11')
    convolutionalUnit(netWidth,1,'S1U2')
    additionLayer(2,'Name','add12')
    reluLayer('Name','relu12')
    convolutionalUnit(2*netWidth,2,'S2U1')
    additionLayer(2,'Name','add21')
    reluLayer('Name','relu21')
    convolutionalUnit(2*netWidth,1,'S2U2')
    additionLayer(2,'Name','add22')
    reluLayer('Name','relu22')
    convolutionalUnit(4*netWidth,2,'S3U1')
    additionLayer(2,'Name','add31')
    reluLayer('Name','relu31')
    convolutionalUnit(4*netWidth,1,'S3U2')
    additionLayer(2,'Name','add32')
    reluLayer('Name','relu32')
    averagePooling2dLayer(8,'Name','globalPool')
    fullyConnectedLayer(2,'Name','fcFinal')
    softmaxLayer('Name','softmax')
    classificationLayer('Name','classoutput')
    ];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'reluInp','add11/in2');
lgraph = connectLayers(lgraph,'relu11','add12/in2');
skip1 = [
    convolution2dLayer(1,2*netWidth,'Stride',2,'Name','skipConv1')
    batchNormalizationLayer('Name','skipBN1')];
lgraph = addLayers(lgraph,skip1);
lgraph = connectLayers(lgraph,'relu12','skipConv1');
lgraph = connectLayers(lgraph,'skipBN1','add21/in2');
lgraph = connectLayers(lgraph,'relu21','add22/in2');
skip2 = [
    convolution2dLayer(1,4*netWidth,'Stride',2,'Name','skipConv2')
    batchNormalizationLayer('Name','skipBN2')];
lgraph = addLayers(lgraph,skip2);
lgraph = connectLayers(lgraph,'relu22','skipConv2');
lgraph = connectLayers(lgraph,'skipBN2','add31/in2');
lgraph = connectLayers(lgraph,'relu31','add32/in2');
options = trainingOptions('sgdm', 'MiniBatchSize',128,'MaxEpochs',10,'InitialLearnRate',1e-4,'ExecutionEnvironment','parallel');
[trainedNet1,traininfo] = trainNetwork(trainData,lgraph,options);
And i get this error:
Error in algo (line 105)
[trainedNet1,traininfo] = trainNetwork(trainData,lgraph,options);
Caused by:
    Error using nnet.internal.cnn.DistributedDispatcher/computeInParallel (line 193)
    Error detected on worker 2.
        Error using augmentedImageDatastore/applyAugmentationPipeline (line 401)
        augmentedImageDatastore cannot form MiniBatches of data because input image sizes differ in 3rd dimension. Consider
        using 'ColorPreprocessing' option to ensure all augmented images have same number of channels.
0 Commenti
Risposte (1)
  Sanyam
      
 il 4 Lug 2022
        It looks like your data set contains images of different color channels like grayscale, rgb etc. matlab does not allow 2 images of different dimensions in a mini-batch. One of the ways would be to convert all your images in grayscale, this can be done by defining augmented datastore like this:
augmentedImageDatastore(inputSize(1:2),yourData,'ColorPreprocessing','rgb2gray');
It converts all the rgb images to grayscale.
Hope that helps! Thanks!
0 Commenti
Vedere anche
Categorie
				Scopri di più su Deep Learning Toolbox in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

