フィルターのクリア

image resize deep learning

1 回表示 (過去 30 日間)
amjad hammad
amjad hammad 2022 年 10 月 30 日
コメント済み: amjad hammad 2022 年 11 月 6 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 10 月 30 日
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 2022 年 11 月 6 日
i have chabged all images to same sizes using resize program
Please if you have code to resize images can you provide me

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 10 月 30 日
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.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by