Effacer les filtres
Effacer les filtres

Labeling images using own trained classifier

3 vues (au cours des 30 derniers jours)
Andrea Magni
Andrea Magni le 25 Août 2018
Commenté : zoulikha le 7 Déc 2022
Hi, I have created a classifier using CNN (vgg16) for the feature extraction and KNN to classify using a dataset made of 1000 images with accuracy of 96% for train and 94% for test. The question is: How can I use my classifier to label one given image? Say I have one image on an apple and I want my classifier to recognize the apple, how can I know the corresponding label of the image (in this case apple)?
What kind of function should I use? predict()?

Réponse acceptée

Image Analyst
Image Analyst le 25 Août 2018
Yes. You can do like this:
newImage = imread(fullfile(rootFolder, 'airplanes', 'image_0690.jpg'));
% Create augmentedImageDatastore to automatically resize the image when
% image features are extracted using activations.
ds = augmentedImageDatastore(imageSize, newImage, 'ColorPreprocessing', 'gray2rgb');
% Extract image features using the CNN
imageFeatures = activations(net, ds, featureLayer, 'OutputAs', 'columns');
% Make a prediction using the classifier
label = predict(classifier, imageFeatures, 'ObservationsIn', 'columns')
See this link and it will walk you through it step by step.
  4 commentaires
Patricia-Carmen Tibre
Patricia-Carmen Tibre le 8 Mai 2020
Modifié(e) : Patricia-Carmen Tibre le 8 Mai 2020
Hello Mr. Image Analyst!
I kinda have the same problem of image labeling. I have to make the classification using SVM and I used CNN to extract features from images. I also have to random the features extracted ( by columns because 1 column = 1 image features ) and when i do that the classification is wrong. Can you give me some tips? I`m thinking that maybe i should have label the columns not the images but maybe I`m wrong. Thank you!
Image Analyst
Image Analyst le 8 Mai 2020
So you used CNN (or I guess RCNN) to collect a bunch of estimated feature values (for example x, y, meanGrayLevel, standard deviation) from a set of images, and now you want to randomize that feature matrix. I guess the feature matrix has image numbers going down the rows, and each feature is in its own column, right? And did you also do a classification CNN (the usual, standard, simplest kind) to get an estimated class for each image? And the predicted class is one column of your feature matrix. So your feature matrix is like
image# predictedClass x y meanGrayLevel StdDev
image1 1 5 8 200 2.5
image2 2 9 3 120 4.9
image3 1 4 6 189 8.4
or something like that?
You can use the randsample() function to extract a subset of your matrix.
Or you can get a random ordering yourself using the randperm() function to scramble the order
sortOrder = randperm(size(featureMatrix, 1));
featureMatrix = featureMatrix(sortOrder, :);

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by