trainNetwork requiring 1x2 cell array from a Transformed image datastore

1 次查看(过去 30 天)
I am trying to train a network using the deep network designer. I started by creating a datastore and then transforming the images to grayscale. These images are then sent to the deep network designer. However, I keep getting an error saying that I need a 1x2 cell array despite using an image datastore.
Below is the code used before:
ds = imageDatastore("Training","IncludeSubfolders",true, "LabelSource","foldernames");
dsnew = transform(ds,@(x) rgb2gray(x));
The images are all 512 x 512, so in ImageInputLayer I have the InputSize set to 512 x 512 x 1.

回答(1 个)

Sourabh
Sourabh 2023-3-23
编辑:Sourabh 2023-3-23
Hi Rayan,
The error message you are seeing might be because the output of transform is not returning the data in the expected format for your neural network.
The “transform function outputs a TransformedDatastore object. With the Deep Network Designer, you can import and train any datastore object that works with the trainNetwork function.
To pre-process images according to your own pipeline, try using the transform and combine functions.
For more information on pre-processing images for deep learning applications, see Preprocess Images for Deep Learning.
As a last resort solution for this issue, you could consider using the “Image Batch Processor” app from the Image Processing Toolbox to perform any pre-processing operations on your image dataset and save them to your local disk.
However, I would only recommend this option if your dataset were small, and you would not mind having a second copy of the images on your disk.

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by