imageDatastore multiple output label
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have created a structure that has the file name, feature/image folder location, and the labeling vector.
My project involves taking a spectrogram image of a musical triad which has three output labels/notes which I have stored as [2;35;66]...[15;23;71].
I cannot add all three labels to a single row of the cell inside the imageDatastore the closest I can is add an Nx1 vector of the first note in the musical triad but not when I try imds.Labels = [Note1Vector ; Note2Vector; Note3Vector] it will give me the error:
Error using indexing
Labels must be a string array, or a cell array of character vectors, or a vector of numeric, logical, or categorical
type.
Thank you.
1 comentario
Yash
el 15 de En. de 2024
Hi Chaz,
Kindly share a sample code with some data to better understand and reproduce the issue that you are facing.
Respuestas (1)
Yash
el 18 de En. de 2024
Hi Chaz,
It seems like you're trying to work with MATLAB's "imageDatastore" to handle a multi-label classification problem, where each image has multiple labels associated with it. The default behavior of "imageDatastore" is to handle single-label scenarios, where each image is associated with one label. However, for multi-label classification, you need to store the labels in a format that "imageDatastore" can accept.
Since "imageDatastore" expects the labels to be a single array or vector, you cannot directly assign a matrix of labels where each image has multiple labels. Instead, you should consider using a cell array where each cell contains the vector of labels for the corresponding image.
Here's how you can structure your labels and assign them to the imageDatastore:
% Assume you have an imageDatastore 'imds' already created with the images loaded
% And you have your labels in the format [2;35;66], [15;23;71], etc.
% Let's say 'labelMatrix' is an Nx3 matrix where each row corresponds to the labels of an image
labelMatrix = [
2, 35, 66;
15, 23, 71;
% ... and so on for all your images
];
% Convert this matrix to a cell array where each cell contains a vector of the labels
labelCellArray = num2cell(labelMatrix, 2);
% Assign this cell array to the Labels property of your imageDatastore
imds.Labels = labelCellArray;
This way, each image will have a cell with a numeric vector corresponding to its labels. When you train your model, you'll need to make sure it can handle this kind of multi-label input. Depending on the deep learning framework you're using (like MATLAB's Deep Learning Toolbox), you might need to customize the data input layer or the loss function to properly handle multi-label targets.
If you still face the issue, kindly share a sample code with some data to better understand and reproduce the issue that you are facing.
Hope this helps!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!