Can I give multiple labels to a single file in ImageDatastore

Can I give multiple categorical labels to a single file in ImageDatastore. For example I have an outdoor photograph which contains a Dog, Tree and Sky. I have Inceptionv3 running in Python with all files in one directory, and the muliple labels held in txt files of same names and want to rebuild this in MATLAB. The only option I can find is ('LabelSouce','foldernames'). Is it possible to add multiple labels to a single file in the Datastore, or do I need to add the file 3 times, once for each label, or use a different method?

11 comentarios

Try giving no source first.....then put your lables in
imds = imageDatastore(location)
imds.labels
imds.Labels is an 1 dimensional array with no of elements equal to no of images. Can I make this into a 2 dimsional array, or could you help with the syntax to put muliple labels in each array element.
It's not very clear how you're planning to generate target outputs for the network using these labels. Do you want independent 1/0 values to predict the presense of each class?
Also..
What's the activation function you are using for the output layer? Is it designed for multi label classification?
Thank you for your comment. I am not sure how to generate target outputs yet, and may not be able to use imds. Yes I want independant 1/0 values for each class.
I have my network running with retrain.py from Tensorflow and am trying to migrate this to MATLAB. changing the last layers of InceptionV3. I am using a custom SIGMOID predictions layer and have written a sigmoid crossentropyclassification layer but get error
Caused by:
Layer 'AHE SCEclassoutput': Missing softmax layer. A classification layer must be
preceded by a softmax layer.
Is this a fundamental limitation, and hence is it possible to do multi label classification in 2018b?
I am also trying to use a two dimensional array for my labels. My network output's dimension is 2, it is for regression, not classification. The function imageDatastore takes only 1 dimensional array for labels. If you find a way how to use a 2 dimensional array, let me know.
Thank you
@Athul Prakash Matlab 2020b has released multi label classification example without creating datastores. The problem discussed here yet persisits to create a imagedatastore with multi-label classification. Could you please enlighten on this? Thanks.
@Abed AlRahman Al Makdah I am trying to do the exact same thing, did you manage to find a solution?
@Abed AlRahman Al Makdah I am trying to label an Image with two of its another features in Matlab using imageDataStore. ie 2D arrays as label. Did you find a solution?
Im using Matlab 2019 b version. pls help
@Yousef Omar did you find any solution?
@Andy Holmes-Evans can you give the solution pls

Iniciar sesión para comentar.

Respuestas (1)

Hi,
To assign multiple labels to a single image in MATLAB, you can use a combination of “imageDatastore” and “arrayDatastore”.
Start by preparing a cell array where each cell contains a categorical array of labels corresponding to each image. Create an “arrayDatastore” with this cell array. Use the “combine” function to merge the image and label datastores.
For example, if you have two images, you can set up the combined datastore as shown below:
labelCellArray = cell(2, 1);
labelCellArray{1} = categorical(["ball" "dog" "cat"]);
labelCellArray{2} = categorical(["tree" "sky"]);
labelDs = arrayDatastore(labelCellArray);
dsTrain = combine(imds, labelDs);
Hope this will be helpful!

Categorías

Más información sobre Preprocess Data for Deep Neural Networks en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 7 de Ag. de 2019

Respondida:

el 4 de Abr. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by