augmentedImageDatastore center crop does not return datastore with labels
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (2)
Sai Bhargav Avula
el 26 de Mayo de 2020
Editada: Sai Bhargav Avula
el 26 de Mayo de 2020
Hi,
imdsTrain = imageDataStore(imageDir);
pxdsTrain = pixelLabelDatastore(labelDir,ClassNames,labelIds);
trainingData = pixelLabelImageDatastore(imds,pxds,'OutputSizeMode','centercrop','OutputSize',[28,28]);
Hope this helps!
4 comentarios
Sai Bhargav Avula
el 26 de Mayo de 2020
Editada: Sai Bhargav Avula
el 26 de Mayo de 2020
The augumentedImageDatastore generally is used to randomly perturbs(augument) the training data for each epoch, so that each epoch uses a slightly different data set. This is majorly to resize images to make them compatible with the input size of your deep learning network. Hence it doesnot hold the label information. But you can use the augmented datastore for training the network and label info is taken inherently.
Refer the following link ; https://www.mathworks.com/help/deeplearning/ref/imagedataaugmenter.html
For explicit training as mentioned there are many ways like performing transform on the datastores seperately etc., Here I have mentioned to use pixelLabelImageDatastore. I have attached the example code for better understanding.
dataSetDir = fullfile(toolboxdir('vision'),'visiondata','triangleImages');
imageDir = fullfile(dataSetDir,'trainingImages');
labelDir = fullfile(dataSetDir,'trainingLabels');
classNames = ["triangle","background"];
labelIDs = [255 0];
imds = imageDatastore(imageDir);
auimds = augmentedImageDatastore([28,28],imds);
pxds = pixelLabelDatastore(labelDir, classNames, labelIDs);
trainingData = pixelLabelImageDatastore(imds,pxds,'OutputSizeMode','centercrop','OutputSize',[28,28]);
When you read the data
read(trainingData)
ans =
1×2 table
inputImage pixelLabelImage
_____________ ___________________
{28×28 uint8} {28×28 categorical}
Which you can use to evaluate accuracies explicitly. I hope this explains and what you are looking for
M J
el 15 de Oct. de 2020
Editada: M J
el 15 de Oct. de 2020
Hello!
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.
el 5 de Dic. de 2020
Editada: Prasobhkumar P. P.
el 5 de Dic. de 2020
Labels of augmentedImageDatastore is is inside the output (see info).
[data,info]=read(augimdsTrain)
I got this info from below post
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!