How to read a single image from a folder and then classify it with a trained neural network?

2 次查看(过去 30 天)
I trained my network for skin tumor classification and then saved it. Now I want to test the accuracy for some new images. It works fine using imageDatastore but what I really want is to be able to browse in my computer for an image and classify it using the trained network. Is this possible?
Below I have attached the test code for a set of images.
load incercare.mat
imds= imageDatastore('E:/LICENTA/BD_Skin_Cancer_Screening/mini_data/test/', ...
'IncludeSubfolders', true, ...
'LabelSource', 'foldernames' );
[YPred,probs] = classify(netTransfer,imds);
accuracy = mean(YPred == imds.Labels)
for i=1:10
subplot(2,5,i)
I = readimage(imds,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label) + ", " + num2str(100*max(probs(idx(i),:)),3) + "%");
end
  1 个评论
Amit
Amit 2021-6-5
Dear Malina,
Accoridng to me Backpropagation Feedforward neural network would be best suited for your purpose.
Please send me your 'incercare.mat' file by email on amit.kenjale@gmail.com, I will analyze this file for its variables and suggest you best suited approach to get your work done..

请先登录,再进行评论。

回答(1 个)

Prateek Rai
Prateek Rai 2021-8-16
To my understanding, you trained the network for skin tumor classification and want to classify a single image using the trained network.
A possible workaround is:
  • Step 1: Read the image.
image = imread(xyz) % xyz is the location of the image in computer.
  • Step 2: You can use use the nework variable and feed the image as its argument to compute the network output.
classificationOutput = netTransfer(image);
You can also refer to Classify Patterns with a Neural Network MathWorks documentation page to find more on classification with a neural network.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by