Yolov5 ONNX conversion

Hi, I tried to convert my trained YOLOV5 file into onnx and convert it using conversion tools

But I encounter this problem. (I used onnx==1.6.0) as the documentation said.
Any idea why this causes the problem of model conversion and how to solve it?
Many thanks in advance. (This model conversion has given me 2 sleepless nights already…)

E Calc node ScatterND_638 output shape fail
W ----------------Warning(2)----------------
Traceback (most recent call last):
File “acuitylib/onnx_ir/onnx_numpy_backend/shape_inference.py”, line 50, in infer_shape
File “/home/wudi/code/amlnn_tools/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/acuitylib/onnx_ir/onnx_numpy_backend/ops/scatter_nd.py”, line 33, in ScatterND
return scatter_nd_impl(data, indices, updates)
File “/home/wudi/code/amlnn_tools/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/acuitylib/onnx_ir/onnx_numpy_backend/ops/scatter_nd.py”, line 24, in scatter_nd_impl
output[indices[i]] = updates[i]

@stevenwudi Can you provide the complete error message, it doesn’t seem to be complete here ?

Here is the error message. Could it be onnx to numpy issue?

Traceback (most recent call last):
  File "acuitylib/onnx_ir/onnx_numpy_backend/shape_inference.py", line 50, in infer_shape
  File "/home/wudi/code/amlnn_tools/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/acuitylib/onnx_ir/onnx_numpy_backend/ops/scatter_nd.py", line 28, in ScatterND
    return scatter_nd_impl(data, indices, updates)
  File "/home/wudi/code/amlnn_tools/aml_npu_sdk_6.4.3/acuity-toolkit/bin/acuitylib/acuitylib/onnx_ir/onnx_numpy_backend/ops/scatter_nd.py", line 21, in scatter_nd_impl
    output[indices[i]] = updates[i]
IndexError: arrays used as indices must be of integer (or boolean) type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "convertonnx.py", line 52, in <module>
  File "convertonnx.py", line 45, in main
  File "acuitylib/vsi_nn.py", line 153, in load_onnx
  File "acuitylib/app/importer/import_onnx.py", line 107, in run
  File "acuitylib/converter/convert_onnx.py", line 62, in __init__
  File "acuitylib/converter/convert_onnx.py", line 220, in _shape_inference
  File "acuitylib/onnx_ir/onnx_numpy_backend/shape_inference.py", line 52, in infer_shape
  File "acuitylib/acuitylog.py", line 251, in e
ValueError: Calc node ScatterND_935 output shape fail
[446] Failed to execute script convertonnx

@stevenwudi Maybe you need to check , are there unsupported layers in the model .

I’m not sure about what happend .

It looks like the array is out of bounds here

I checked, the index i in the following quote is floating number.

I will further check what is this scatter function doing and try to correct the float to int, I will keep you posted @Frank

One more thing, can we convert .onnx, is the script trying to go from the output backward to input? (It seems the case from my understanding: cause the error will start from the output first…). Could you kindly help to clarify that @Frank . Thanks a lot!

1 Like

@stevenwudi The code is not open source. To be honest, I have a lot of questions, but there is no way to verify

There is the same question of us too, some cases indicate that the ScatterND is not a supported operator when transfer .onnx to TRT. But we can not analyze the problem there, is the mistake of data’s shape causing this problem or the ScatterND is also not supported in RKNN. This will guide us to choose verify the data’s shape or to rewrite ScatterND in YOLOv5.
Have you solved this problem,please provide some details of steps. Thanks!

No, we never solved the problem. Acuity toolkit sucks. Simply use Tengine as inference engine, it will solve us so many more nightmares
GitHub - OAID/Tengine: Tengine is a lite, high performance, modular inference engine for embedded device.