MATLAB Answers

0

Image Regression using .mat Files and a datastore

Asked by Matthew Fall on 29 Apr 2019
Latest activity Answered by Lykke Kempfner on 16 Aug 2019 at 7:23
I would like to train a CNN for image regression using a datastore. My images are stored in .mat files (not png or jpeg). This is not image-to-image regression, rather an image to single regression label problem. Is it possible to do this using a datastore, or at least some other out-of-memory approach?

  0 Comments

Sign in to comment.

2 Answers

Answer by Johanna Pingel on 29 Apr 2019
Edited by Johanna Pingel on 29 Apr 2019

I've used a .mat to imagedatastore conversion here:
imds = imageDatastore(ImagesDir,'FileExtensions','.mat','ReadFcn',@matRead);
function data = matRead(filename)
inp = load(filename);
f = fields(inp);
data = inp.(f{1});

  1 Comment

Thank you for your swift reply.
Unfortunately, the matlab regression example requires loading all of the training and validation data in memory, which I want to avoid by using the datastore.
I've tried using the imageDatastore with regression labels before, but then trainNetwork gives me the error:
Error using trainNetwork (line 150)
Invalid training data. The labels of the ImageDatastore must be a categorical vector.

Sign in to comment.


Answer by Lykke Kempfner on 16 Aug 2019 at 7:23

I have same problem.
I have many *.mat files with data that can not fit in memory. You may consider the files as not standard images. I have the ReadFunction for the files. I wish to create a datastore (?) where each sample are associated with two single values and not a class.
Are there any solution to this issue ?

  0 Comments

Sign in to comment.