Imagedatastore for image regression, resize image from table

3 Ansichten (letzte 30 Tage)
Iker Garmendia
Iker Garmendia am 23 Mai 2023
Beantwortet: Neha am 29 Mai 2023
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

Antworten (1)

Neha
Neha am 29 Mai 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!

Kategorien

Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by