Imagedatastore for image regression, resize image from table

4 次查看(过去 30 天)
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

回答(1 个)

Neha
Neha 2023-5-29
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!

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by