trainNetwork requiring 1x2 cell array from a Transformed image datastore

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 日

0 投票

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

質問済み:

2022 年 11 月 29 日

編集済み:

2023 年 3 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by