Issues loading labels in Deep Network Analyzer

조회 수: 5 (최근 30일)
Fred Severgnini
Fred Severgnini 2023년 6월 23일
댓글: Aniketh 2023년 7월 10일
Hello all,
I am configuring a neural network for keypoint detection. Each input is an image, and the label for each image is one single number. This number corresponds to a value in the xcoordinate of the image.
I have a table with the labels for my images, and I am assigning the right label to each image in the datastore by doing the following:
%ground truth is a table, pos_pixel is one of its cols, containing the
%label I need for that image
%the resulting img_datastore.Labels is an array of doubles
img_datastore.Labels(j) = ground_truth.pos_pixel(i);
After creating these labels, I go to "import custom data", and get the following:
"Invalid training data. The labels of the ImageDatastore must be a categorical vector."
Does anyone know why this could be happening? Thanks in advance.
  댓글 수: 1
Fred Severgnini
Fred Severgnini 2023년 6월 23일
additionally, here's how I'm creating the datastore:
img_datastore = imageDatastore('C:\Users\Admin\Desktop\keypoint_inputs\2022_11_16c\images');

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

답변 (1개)

Aniketh
Aniketh 2023년 7월 8일
Hi,
In the trainNetwork function, the response input (Labels) is expected to be a categorical array. However, in the provided code, the labels are assigned directly from a table column, and ends up as an array.
To resolve this issue, you need to convert the labels to a categorical vector using the categorical() function. To fix the problem, modify the code as follows:
img_datastore.Labels(j) = categorical(ground_truth.pos_pixel(i));
For more information you can read up on these pages:
Hope this was helpful!
  댓글 수: 2
Fred Severgnini
Fred Severgnini 2023년 7월 10일
Hello Aniketh,
Thank you for your answer.
Upon further inspection, it seems my main issue is that the system is expecting the output to be categories only (i.e. to classify elements in images as being birds, dogs etc).
The network I am trying to build is supposed to output a number, which is the x-axis coordinate of an element in the image.If the system receives the coordinates as categories, this will compromise the loss calculations.
Do you know if there is a way to change this expected output?
Aniketh
Aniketh 2023년 7월 10일
According to the documentation on imageDatastore, the lables can be of the type categorical | cell | logical | double | single | string, so probably what is happening here is when you load the images, it is assigning labels as the filenames, and not allowing you to change the datatype.
You can read more about how this works at imageDatastore. One workaround to this is using the combine function and use it to create a CombinedDatastore. You would have to store the labels as a datastore object to accomplish this, there is suffecient documentation on how to convert tabular/spreadsheets etc . It would require some extra work, but can be done.
Using imageDatastore give you a very abstracted view of these operations, and thus provides less customizability such as labelling images directly through tables, hope this helped!

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

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by