i have done image classification using cnn and used kfold validation. can any one help me "how to display the misclassified images in matlab?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i have done image classification using cnn. now i want to show and i want to display the misclassified images. and i have used 5fold validation for training cnn. And also can you tell me reason behind the missclassification.
0 comentarios
Respuestas (1)
Siraj
el 20 de Sept. de 2023
Hi!
It is my understanding that you have trained a Convolutional Neural Network (CNN) for image classification using a 5-fold validation approach and wants to display the misclassified images.
To achieve the above goal, first, make predictions on the validation/testing set using the trained CNN model. This can be done by using the “classify” function. Then identify the misclassified images by comparing the predicted labels with the actual labels.
Retrieve the indexes of the misclassified images using the “find” function. Read the misclassified image data using “readimage” and display each misclassified image using the “imshow” function.
For a better understanding I’ve attached the code below.
% Train the network
net = trainNetwork(imdsTrain, layers, options);
% Make predictions on the validation set
YPred = classify(net, imdsValidation);
% Find misclassified images
wronglyPredicted = YPred ~= imdsValidation.Labels;
misclassified_image_indexes = find(wronglyPredicted);
% Display misclassified images with actual and predicted labels
for i = 1:numel(misclassified_image_indexes)
image_index = misclassified_image_indexes(i);
img = readimage(imdsValidation, image_index);
figure, imshow(img)
title("Actual label = " + char(imdsValidation.Labels(image_index)) + " Predicted Label = " + char(YPred(image_index)))
end
To gain a better understanding of the “readimage” and “find” functions and how they are used to find and read misclassified images, you can refer to the following links:
Hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!