No appropriate method, property, or field 'Lables' for class 'matlab.io.datastore.ImageDatastore'.
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ABINAYASUNDARI R
le 21 Déc 2019
Modifié(e) : Sunil Prajapati
le 15 Oct 2020
I am trying to classify two class of images with resnet-50 in deep learning and getting an error 'No appropriate method, property, or field 'Lables' for class 'matlab.io.datastore.ImageDatastore'..
Can anyone help. This is my code
clc
%%Image Folder%%
outputFolder = fullfile('input folder');
rootFolder = fullfile(outputFolder, 'CNN_Class');
categories = {'a','b'};
%%Datastore for storing the images%%
imds = imageDatastore(fullfile(rootFolder, categories),'LabelSource', 'foldernames');
tbl=countEachLabel(imds);
minSetcount=min(tbl{:,2});
imds=splitEachLabel(imds,minSetcount,'randomize');
countEachLabel(imds);
net=resnet50();
set(gca,'YLim',[150 170]);
net.Layers(1);
net.Layers(end);
numel(net.Layers(end).ClassNames);
%%Split into Training and Testing set%%
[trainingSet,testSet] = splitEachLabel(imds,0.8,'randomized');
imageSize=(net.Layers(1).InputSize);
augmentedTrainingset=augmentedImageDatastore(imageSize,trainingSet);
augmentedTestset=augmentedImageDatastore(imageSize,testSet);
w1=net.Layers(2).Weights;
w1=mat2gray(w1);
% figure
%montage(w1)
title('First Convolution Layer Weight')
featureLayer='fc1000';
trainingFeatures=activations(net,augmentedTrainingset,...
featureLayer,'MiniBatchSize',32,'OutputAs','Columns');
trainingLabels=trainingSet.Labels;
Classifier=fitcecoc(trainingFeatures,trainingLabels,...
'Learner','Linear','Coding','onevsall','ObservationsIn','Columns');
testFeatures=activations(net,augmentedTestset,...
featureLayer,'MiniBatchSize',32,'OutputAs','Columns');
predictLabels=predict(Classifier,testFeatures,'ObservationsIn','Columns');
testLables=testSet.Lables;
confMat=confusionmat(testLables,predictLables);
confMat=bsxfun(@rdivide,confMat,sum(confMat,2));
mean(diag(confMat))
0 commentaires
Réponse acceptée
dpb
le 22 Déc 2019
It's spelled "labels", not "lables"
testLabeles=testSet.Lables;
should be
testLabels=testSet.Labels;
Of course, let the auto-correct feature fix the other places it can and manually correct the other places as well. Judicious use of the text substitution can help typing here.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Data Workflows 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!