augmentedImageDatastore center crop does not return datastore with labels

조회 수: 16(최근 30일)
I have an image datastore which includes images and labels. Before feeding to the network, I want to crop the images at the center. However, I noticed that imdsTrain_crop does not have label information as imdsTrain does.
imdsTrain_crop = augmentedImageDatastore([28,28],imdsTrain,'OutputSizeMode','centercrop');
Notice below how the ImageDatastore object has Labels but the augmentedImageDatastore does not. Is there any way to work around this?
I know that augmentedImageDatastore.Files will have information of the filepath for each image, which I can read and then label accoordingly, but this seems troublesome when there could be a simpler solution.


Sai Bhargav Avula
Sai Bhargav Avula 2020년 5월 26일
편집: Sai Bhargav Avula 2020년 5월 26일
One way to address this is to use pixelLabelDatastore for loading the labels
pixelLabelImageDatastore to create the datastore for training.
imdsTrain = imageDataStore(imageDir);
pxdsTrain = pixelLabelDatastore(labelDir,ClassNames,labelIds);
trainingData = pixelLabelImageDatastore(imds,pxds,'OutputSizeMode','centercrop','OutputSize',[28,28]);
or transform function over the datastores.
Hope this helps!
  댓글 수: 4
M J 2020년 10월 15일
편집: M J 2020년 10월 15일
I have a function that creates a random subset of n images (according to a set of rules) from the original training dataset. Basically, each random subset has the same size as the miniBatch, so I would then have one random subset (batch) passed in the network at every iteration.
Can I achieve this by transforming the datastore and using this type of command ?
fds = fileDatastore(TrainingImages.Files,'ReadFcn',@myRandomSubsetFunction)
I am not sure about how to retrieve the labels in this new datastore and how to pass it to the "trainNetwork" function. I would greatly appreciate your help, if possible. Thank you in advance.

댓글을 달려면 로그인하십시오.

Prasobhkumar P. P.
Prasobhkumar P. P. 2020년 12월 5일
편집: Prasobhkumar P. P. 2020년 12월 5일
Labels of augmentedImageDatastore is is inside the output (see info).
I got this info from below post

Community Treasure Hunt

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

Start Hunting!

Translated by