How to prepare imagedatastore for Image to single value regression

14 次查看(过去 30 天)
I would like to train a CNN for image regression using a datastore. The output is a single value. I set the Labels in imagedatastore to a value vector(Y_train). But the debug information show the labels in imagedatastore must be a categorical vetcor. Is it possible to use the imagedatastore for regression problems.
ims_train = imageDatastore('F:\imagestore\train_image224', 'FileExtensions', '.tiff', 'Labels', Y_train, 'ReadSize', 128);
% here I defined my network architecture
% here I defined my training options
[net,Info] = trainNetwork(ims_train,lgraph,options);
  3 个评论
Cris LaPierre
Cris LaPierre 2021-1-5
编辑:Cris LaPierre 2021-1-5
Question from Sho Wright
Hi Qi Lu, I'm also trying to use imds and augimds to preprocess images for an image-to-value regression network, could you share your code if possible?
Cris LaPierre
Cris LaPierre 2021-1-5
Qi lu's reply
Sorry. I don't find any solutions or workaround. It seems it's impossible to use imds to solve regression problems since the he labels in imagedatastore must be a categorical vetcor. But the labels in regression problems are values. Now I just load all image in the RAM and process image.

请先登录,再进行评论。

回答(1 个)

Joe Chalfoun
Joe Chalfoun 2021-8-12
编辑:Joe Chalfoun 2021-8-12
This solution worked for me:
Just get the list of files name from the regular imagedatastore and create a table of two columns, the first one is the files name and the second column is the regression response. You can then input that table to trainNetwork function or for the validation option too, like this:
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));
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by