Imagedatastore for image regression, resize image from table
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Neha
on 29 May 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!
0 Comments
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!