Clear Filters
Clear Filters

Using imageDatastore to load Input image and get output as predicted image

19 views (last 30 days)
Hi,
I am trying to see if I can load few images as an input to a supervised ML model and predict an image as output of the model.
I came across imageDatastore() to load images with Label values too. I want to know how I can load my training input and output image dataset to train the supervised ML model.
Here is what I tried,
dataTrain_dir = "D:\RahulGulia\iMHS_rahul\Dataset\Dataset_Warehouse_Config_3_Tensors_cropped_Sample\Perm_tensors"
dataTrainLabel_dir = "D:\RahulGulia\iMHS_rahul\Dataset\Dataset_Warehouse_Config_3_Tensors_cropped_Sample\SINR_tensors"
imds = imageDatastore(data_dir,"LabelSource",dataTrainLabel_dir)
but got an error saying:
Error using imageDatastore
Expected input to match one of these values:
'none', 'foldernames'
Kindly let me know if I can directly train the model in MATLAB using the images as input and also as an output. Or should I send the image as matrix to the ML model. Looking forward to any kind of suggestion. I would really appreciate it.
Thank you,
Rahul

Answers (1)

Matt J
Matt J on 8 Apr 2024 at 17:05
Edited: Matt J on 8 Apr 2024 at 17:08
and predict an image as output of the model.
Labels are text scalar that are assigned to an image in a classification problem. Conversely your output is an image, so it appears you have an image-to-image regression problem. For that, you would need a CombinedDatastore:
XTrain_dir = "D:\RahulGulia\iMHS_rahul\Dataset\Dataset_Warehouse_Config_3_Tensors_cropped_Sample\Perm_tensors"
YTrain_dir = "D:\RahulGulia\iMHS_rahul\Dataset\Dataset_Warehouse_Config_3_Tensors_cropped_Sample\SINR_tensors"
xstore = imageDatastore(XTrain_dir);
ystore = imageDatastore(yTrain_dir);
xystore=combine(xstore,ystore);
Or, perhaps you have a semantic segmentation problem, in which case you could use a pixelLabelDatastore, assuming you have the Computer Vision Toolbox.
  2 Comments
Rahul Gulia
Rahul Gulia on 8 Apr 2024 at 19:14
Thanks, I was also thinking of something like this.
But somehow, the ML and DL models are not able to access the imageDatastore created like this. Any idea, why would it do that?
Matt J
Matt J on 9 Apr 2024 at 14:57
Edited: Matt J on 9 Apr 2024 at 16:16
Not without seeing the LayerGraph that you're trying to train.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!