Azzera filtri
Azzera filtri

Imagedatastore for image regression, resize image from table

4 visualizzazioni (ultimi 30 giorni)
I have used the following link to prepare imagedatasotre for Image to single value regression:
For training:
[net, info] = trainNetwork(table(ims_train.Files,Y_train),lgraph,training_options);
to add validation data:
options = trainingOptions('ValidationData',table(ims_val.Files,Y_val));
However, when I try to train the network I get the following error:
"Error using trainNetwork
The training images are of size 288×382×3 but the input layer expects images of size 256×256×3."
When I create de ImageDatastore I use the 'ReadFcn' option to resize the image.
Is there a way to keep the ReadFcn and not have to rescale all the images in their folders?
Thank you

Risposte (1)

Neha
Neha il 29 Mag 2023
Hi Iker,
I understand that you want to resize the images to train the model while retaining the original size of the images in the folder. To achieve this, there are alternatives to "ReadFcn" as explained in Preprocess images for Deep Learning. You can refer the code given below to use image augmentation to resize each image on-the-fly during training/validation.
augmenter = imageDataAugmenter();
% variable "imds": imageDataStore
augimdsTrain = augmentedImageDatastore([256,256], imds, 'DataAugmentation', augmenter);
Hope this helps!

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by