Creating Table with proper format in Matlab for YOLO v3 example?

150 Views Asked by At

Matlab has a fairly extensive suite of examples for object detection using Neural Networks.

In the YoloV3 example, the tools need as input a table with a particular format. I have a custom dataset, with custom boxes, but am not able to get the table formatted correctly.

The "expected" format for this table is something that looks like this (when viewed in the data explorer)

Table Screenshot

i.e. a table where the Vehicle column has arrays of 4 elements.

Now, I defined my own table as follows:

>>myStruct(1)
ans = 
  struct with fields:

    imageFilename: 'E:\data\NeuralNetwork\cornertrain1\0c7a2fcc-1ff6-4582-b982-70e2c3f710b9.jpg'
          vehicle: [183 145 494 82]
>> cornerTable = struct2table(myStruct);

But it's format is quite different, it has 1 vehicle column with 4 subcolumns.

screenshot of my table

How do I make a table with my struct with a format so that the "vehicle" column has arrays of 4 elements?

1

There are 1 best solutions below

2
John On

The issue was a misunderstanding I had of how tables work.

To determine the datatype of a column of a table, use the class function. So, in the original table, we have:

>> class(vehicleDataset.imageFilename)
ans =
    'cell'
>> class(vehicleDataset.vehicle)
ans =
    'cell'

And the solution I posed, is not using cell arrays at all. The better way to do this construction is to create two cell arrays,

  • one named imageFilename containing char arrays,
  • one named vehicle containing 4 element arrays.

Then, the standard table command "just works"

result = table(imageFilename, vehicle);

I realized this after I posted the question.