imageDatastore multiple output label

조회 수: 18 (최근 30일)
Chaz Minkler
Chaz Minkler 2024년 1월 7일
답변: Yash 2024년 1월 18일
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
Yash
Yash 2024년 1월 15일
Hi Chaz,
Kindly share a sample code with some data to better understand and reproduce the issue that you are facing.

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

답변 (1개)

Yash
Yash 2024년 1월 18일
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!

카테고리

Help CenterFile Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by