Labeling images using own trained classifier
3 次查看(过去 30 天)
显示 更早的评论
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()?
采纳的回答
Image Analyst
2018-8-25
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')
4 个评论
Patricia-Carmen Tibre
2020-5-8
编辑:Patricia-Carmen Tibre
2020-5-8
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
2020-5-8
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, :);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!