"YOLOv8 Custom Model Conversion to .nb - Shape Inference Error"

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu 22.04 on VIM3

Which version of system do you use? Please provide the version of the system here:

VIM3 (Khadas VIM3, not VIM3L)
Ubuntu 22.04.3 LTS
KSNN Convert tools v1.4
aml_npu_sdk-ddk-6.4.8.7-250427

Please describe your issue below:

I’m trying to convert a custom YOLOv8 crowd detection model to .nb format for VIM3 NPU inference.

Steps taken:

  1. Exported PyTorch model (best.pt) to ONNX format successfully (best.onnx - 12.1 MB)
  2. Prepared calibration dataset (100 crowd detection images, 468.75 MB)
  3. Attempted conversion using KSNN converter with command:

./convert --model-name human --platform onnx --model ./human.onnx --input-size-list “3,640,640” --inputs images --outputs output0 --mean-values “127.5 127.5 127.5 0.007843137” --quantized-dtype asymmetric_affine --source-files ./data/dataset/dataset0.txt --kboard VIM3 --print-level 1

The ONNX model exports successfully, but the converter fails during shape inference with an invalid dimension (1,0,160,160).

Can you help with:

  1. Why this error occurs?
  2. Is there a workaround or newer converter version?
  3. Alternative conversion method for custom YOLOv8 models?

Post a console log of your issue below:

--+ KSNN Convert tools v1.4 +--
Start import model ...
I Namespace(import='onnx', input_dtype_list=None, input_size_list='3,640,640', inputs='images', model='./human.onnx', output_data='Model.data', output_model='Model.json', outputs='output0', size_with_batch=None, which='import')
I Start importing onnx...
I Current ONNX Model use ir_version 9 opset_version 20
[24] Failed to execute script pegasus
Traceback (most recent call last):
  File "pegasus.py", line 131, in <module>
  File "acuitylib/converter/onnx/convert_onnx.py", line 761, in _shape_inference
  File "acuitylib/onnx_ir/onnx_numpy_backend/smart_toolkit.py", line 636, in multi_direction_broadcast_shape
ValueError: operands could not be broadcast together with shapes (1,0,160,160) (1,16,160,160)

Hello @uav_e

You can try the orignal tool to convert the model , if still fail, you may need to modify your model.

actually my custom yolo model is obb based is that a problem