How can I use images which have different size for CNN?

24 vues (au cours des 30 derniers jours)
Ersad Mert Mutlu
Ersad Mert Mutlu le 20 Fév 2022
Commenté : Ersad Mert Mutlu le 20 Fév 2022
Hello everyone,
I have prepared a neural network and I need to test it now but my dataset has images that have different sizes. How can I use all of them even they have different size?

Réponse acceptée

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh le 20 Fév 2022
except some special cases, there is a limitation for forwarding different size arrays toward a CNN. after images pass the convolutional layers each one lead to an array with different size. and because of fully connected layers at end of network it is not possible to work with different size array. ( they should work with input with certain size)
so you should convert them to certain size for this network. and there is a fast method to do so:
input_size = Net.Layers(1).InputSize;
images_folder_path = 'E:\images'; % the folder contain all images
image_database = imageDatastore(images_folder_path);
image_database = transform(image_database,,@(x) (imresize(x,input_size(1:2))));
after this, you can pass this datastore to network all in once. for example with classification:
Output = classify(Net,image_database);
if not, select one by one and pass it through the network:
I = image_database.read;
y = classify(Net,I);
  1 commentaire
Ersad Mert Mutlu
Ersad Mert Mutlu le 20 Fév 2022
Thanks a lot. I will use it as soon as possible.

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