Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

There are errors loading custom TinyYolo graph

idata
Employee
741 Views

Hey guys,

 

I am a bit stuck here, let's load something simple, my custom caffe model has 2 categories (let's say dog and cat), and I need TinyYolo to load dog so that the second custom net would give me the breed of the dog, same goes with cat. (this is just an guide I am trying to write, please don't tell me the tiny_yolo already have cats and dogs, what if I add marine mammals as 3rd option) . So first I changed line 19 and 20 on stream_ty_gn_threaded.py

 

https://github.com/movidius/ncappzoo/blob/master/apps/stream_ty_gn_threaded/stream_ty_gn_threaded.py

 

After that I am trying to change

 

https://github.com/movidius/ncappzoo/blob/master/apps/stream_ty_gn_threaded/tiny_yolo_processor.py

 

First thing I did is changing line 207 and 212, where the array only have 2 items now, ['cat','dog'], [1,1]

 

But line 228 keeps giving me error

 

classification_probabilities = \

 

np.reshape(inference_result[0:980], (grid_size, grid_size, num_classifications))

 

ValueError: cannot reshape array of size 2 into shape (7,7,2)

 

Whole code that's causing issue is here, I tried to change grid_size, boxes_per_grid_cell, but none of the combination works, I am not really sure how this part of the code work and how can I load my own custom model?

 

num_classifications = len(network_classifications) # should be 20 grid_size = 7 # the image is a 7x7 grid. Each box in the grid is 64x64 pixels boxes_per_grid_cell = 2 # the number of boxes returned for each grid cell # grid_size is 7 (grid is 7x7) # num classifications is 20 # boxes per grid cell is 2 all_probabilities = np.zeros((grid_size, grid_size, boxes_per_grid_cell, num_classifications)) # classification_probabilities contains a probability for each classification for # each 64x64 pixel square of the grid. The source image contains # 7x7 of these 64x64 pixel squares and there are 20 possible classifications classification_probabilities = \ np.reshape(inference_result[0:980], (grid_size, grid_size, num_classifications))
0 Kudos
4 Replies
idata
Employee
482 Views

@Nyceane,

 

The issue seems to be related to the mismatch in the shape of the 2 parameters you are passing to Numpy.reshape. The second parameter is hard coded to be a 3D array (7x7x2 in your case), but looks like the first parameter (inference_result[0:980]) is passing only a 2D array. The value of inference_result is defined by do_inference, so make sure that output is a 3D array. See:

 

return self._filter_objects(output.astype(np.float32), input_image_width, input_image_height)

 

Tagging @neal_at_intel, the author of this code.

0 Kudos
idata
Employee
482 Views
0 Kudos
idata
Employee
482 Views

@Nyceane For inference, Tiny Yolo returns an array of floats that can be interpreted as follows:

 

     

  • The first 980 float values correspond to each 7x7 grid cell and each of the 20 classes in the data set.
  •  

  • The next 98 float values correspond to the confidence values of each of the 2 bounding boxes anchored within each grid.
  •  

  • The remaining values are the bounding box coordinates (x,y,w,h) for each of the 2 bounding boxes in the grid cells.
  •  

 

Make sure that your app includes a threshold for filtering out low confidence objects and duplicate bounding boxes. You can use the Tiny Yolo appzoo projects as reference. Thanks.

0 Kudos
idata
Employee
482 Views

Hey Ashwin,

 

[ 0.5 0.49975586]

 

[ 0.5 0.49975586]
0 Kudos
Reply