Azzera filtri
Azzera filtri

image resize deep learning

1 visualizzazione (ultimi 30 giorni)
amjad hammad
amjad hammad il 30 Ott 2022
Commentato: amjad hammad il 6 Nov 2022
i have problem in image size in matlab
Error using trainNetwork (line 183)
Unexpected image size: All images must have the same size.
Error in neuralkadoplnenienulami (line 58)
net = trainNetwork(imgsTrain,layers,options);
%Trenovacie data pre siet
trainingDataPath = fullfile('C:\Users\amjad\Desktop\COVID-19-master\doplnenie nulami (1)\Triedenie');
trainingImages = imageDatastore(trainingDataPath,'IncludeSubfolders',true,'LabelSource','foldernames');
% Zobrazenie nahodnych trenovacich dat
figure;
perm = randperm(169,16);
for i = 1:16
subplot(4,4,i);
imshow(trainingImages.Files{perm(i)});
end
% Pocet fotografii v jednotlivych triedach
labelCount = countEachLabel(trainingImages);
% Velkost trenovacich fotiek
img = readimage(trainingImages,1);
[sizeR, SizeC] = size(img);
%specifikovanie poctu trenovacich a validacnych dat
numTrainData = 75;
[imgsTrain,imgsValidation] = splitEachLabel(trainingImages,numTrainData,'randomize');
%Definovanie architektury siete
layers = [
imageInputLayer([sizeR SizeC 1])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(1,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',20, ...
'Shuffle','every-epoch', ...
'ValidationData',imgsValidation, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(imgsTrain,layers,options);
%Klasifikacia dat s vyhodnotenim
clasifydataPath = fullfile('C:\Users\amjad\Desktop\COVID-19-master\doplnenie nulami (1)\Klasifikacia');
clasifyingImages = imageDatastore(clasifydataPath,'IncludeSubfolders',true,'LabelSource','foldernames');
YPred = classify(net,clasifyingImages);
YValidation = clasifyingImages.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation);
missclassifaction = find(YPred ~= YValidation);
missclassifaction = transpose(missclassifaction);
FP = sum(missclassifaction (:)>8);
FN = sum(missclassifaction (:)<9);
TN = 8-FP;
TP = 8-FN;
  2 Commenti
KALYAN ACHARJYA
KALYAN ACHARJYA il 30 Ott 2022
Dear Amjad, before train the model, why do not perfoem just 2 line code to make all images in same size.
amjad hammad
amjad hammad il 6 Nov 2022
i have chabged all images to same sizes using resize program
Please if you have code to resize images can you provide me

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 30 Ott 2022
https://www.mathworks.com/help/deeplearning/ref/augmentedimagedatastore.html
You use an augmented image data store. That allows you to specify an output size. It also allows you to set rgb or grayscale and will automatically convert images as needed.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by