This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-TDA4VM: Decode edgeai-yolov5 output-layer with for-loop

Part Number: SK-TDA4VM

Decode edgeai-yolov5 output-layer with for-loop

I freeze the edgeai-yolov5 with sigmoid.and the input_size is 1x3x384x384, the output_size is 1x255x6x6, 1x255x12x12, 1x255x24x24, 1x255x48x48. And I decode the .bin net with for-loop, the following is the code I use,

Is it right?

and the results are drawed in picture.

some boxes are not in the right place. what's wrong with my code?

  • Hi Yuanfu,

    Visually, the boxes look shifted to the left. If the model is outputting correctly, then I am assuming there is something different between the calculations for computing the center for y and x coordinate. 

    From a quick look at your code snippet, I do not see much differences between the calculation for x and y. However, one difference I do see is in this line:

    float x = (float)pOut[outIdx]/256; 

    Could you change this line to:

    float x = (float)pOut[outIdx]/256.; 

    For the calculation for x, there is no "." after 256 like the calculation for float y. It could be that the type of pOut[outIdx] and 256 are both integers and not float values, which causes the calculation to estimate to the nearest integer. And the addition of the "." is converting 256 into a float value which switches the calculation to use float value instead of integers.

    Regards,

    Takuma

  • I change the line like this, where outTensorScale is float and value is 256.0.  But there is nothing changed

     with the box! Are there any other possible problems? such as wrong used of padding value?

  • Hi Yuanfu,

    If the calculations are correct, then it is most likely the output from the model is skewed. I will get in contact with the TIDL team about this.

    While we wait for their response, I found an E2E about padding that may be relevant. Reading this E2E, it seems padding can automatically be added:

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/986763/tda4vm-tidl-output-size-question

    Could you try the fix they have implemented?

    Regards,

    Takuma

  • HI duan.
     I use the same way as you mentioned,my onnx model are like but i dont know how to set the Configuration files for the tidl_model_import.out .i'm try to convert onnx model to net.bin.
    could you please share your config file and the 

  • Hi duan,I use the similar way you mentioned. I'm try to conver a onnx model lik below with 3 output _size is 1x48x20x20, 1x48x40x40, 1x48x80x80.

    I dont know how to edit the config file needed by the tidl_model_import.out tool.

    would be obliged if you can share me your config file or the way you generate the net.bin file.

  • Hi  Yuanfu,

     Are you getting the correct detection after a similar fix as suggested earlier.

    Regards, Debapriya

  • HI Gang, 

    What are the 48 channels for each tensor? Are you getting the correct detections?

    Regards, Debapriya

  • Hi Debapriya,
    the 48 channels is 3 anchor and each anchor can predict [xy,w,h,obj_score,class_cof,5landmark_point(x,y)]
    I'm a little confused with yuanfu's decode.the out put decode in user guide is NCHW

    • Following example is for the output but same format is also applicable for input
      */
      OutElemTemplateType outPtrStart = &outPtr[outPadT[outIdx] + outPadL[outIdx]];
      int32_t outLinePitch = outWidth[outIdx] + outPadL[outIdx] + outPadR[outIdx];
      int32_t outBatchPitch = outChannelPitch[outIdx] * outNumChannels[outIdx];
      float32_tidl outputVal;
      for ( batchIdx = 0; batchIdx < outNumBatches[outIdx];batchIdx++)
      {
      for ( channelIdx = 0; channelIdx < outNumChannels[outIdx];channelIdx++)
      {
      for ( heightIdx = 0; heightIdx < outHeight[outIdx];heightIdx++)
      {
      for ( widthIdx = 0; widthIdx < outWidth[outIdx];widthIdx++)
      {
      int32_t outIdx = widthIdx +(heightIdx * outLinePitch) +(channelIdx * outChannelPitch[outIdx]) +(batchIdx * outBatchPitch);
      /* Note that this is the final de-quantized output */
      outputVal = outPtrStart[outIdx] / outTensorScale[outIdx];
      printf("Output Element %f \n", outputVal);
      }
      }
      }
      }

    while yuanfu is NHWC.which one is right.

  • HI,

     TIDL output format is NCHW. Please refer to this documentation for more details on decoding TIDL output:

    software-dl.ti.com/.../md_tidl_fsg_io_tensors_format.html

    Regards, Debapriya