How to prepare imagedatastore for Image to single value regression

15 visualizaciones (últimos 30 días)
qi lu
qi lu el 5 de Ag. de 2020
Editada: David el 11 de Mayo de 2022
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 comentarios
Cris LaPierre
Cris LaPierre el 5 de En. de 2021
Editada: Cris LaPierre el 5 de En. de 2021
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 el 5 de En. de 2021
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.

Iniciar sesión para comentar.

Respuestas (1)

Joe Chalfoun
Joe Chalfoun el 12 de Ag. de 2021
Editada: Joe Chalfoun el 12 de Ag. de 2021
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.
  1 comentario
David
David el 11 de Mayo de 2022
Editada: David el 11 de Mayo de 2022
The internet and helpful people save the day. Thank you!

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by