Borrar filtros
Borrar filtros

Issues loading labels in Deep Network Analyzer

2 visualizaciones (últimos 30 días)
Fred Severgnini
Fred Severgnini el 23 de Jun. de 2023
Comentada: Aniketh el 10 de Jul. de 2023
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 comentario
Fred Severgnini
Fred Severgnini el 23 de Jun. de 2023
additionally, here's how I'm creating the datastore:
img_datastore = imageDatastore('C:\Users\Admin\Desktop\keypoint_inputs\2022_11_16c\images');

Iniciar sesión para comentar.

Respuestas (1)

Aniketh
Aniketh el 8 de Jul. de 2023
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 comentarios
Fred Severgnini
Fred Severgnini el 10 de Jul. de 2023
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 el 10 de Jul. de 2023
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!

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by