运行04_inference.sh时报错

在运行04_inference.sh时报错:

下面是log:

2023-08-15 16:46:30,101 file: tool_utils.py func: tool_utils line No: 73 log will be stored in /open_explorer/ddk/samples/ai_toolchain/horizon_model_convert_sample/04_detection/03_yolov5x/mapper/inference.log

2023-08-15 16:46:32,561 file: tool_utils.py func: tool_utils line No: 131 exception in command: main

2023-08-15 16:46:32,562 file: tool_utils.py func: tool_utils line No: 132 Traceback (most recent call last):

File “/usr/local/lib/python3.8/dist-packages/horizon_tc_ui/utils/tool_utils.py”, line 129, in __decorator

func(*args, **kargs)

File “../../det_inference.py”, line 67, in main

inference(sess, image, input_layout, input_offset)

File “../../det_inference.py”, line 36, in inference

postprocess(output, model_hw_shape, origin_image)

File “/open_explorer/ddk/samples/ai_toolchain/horizon_model_convert_sample/04_detection/03_yolov5x/mapper/postprocess.py”, line 57, in postprocess

model_output[0] = model_output[0].reshape([1, 84, 84, 3,

ValueError: cannot reshape array of size 345600 into shape (1,84,84,3,18)

2023-08-15 16:46:32,562 file: tool_utils.py func: tool_utils line No: 133 cannot reshape array of size 345600 into shape (1,84,84,3,18)

您好,地平线工具链在持续迭代优化,为了给您提供更好的服务,希望您能抽出3分钟左右的时间,将您在使用工具链期间的感受和建议告诉我们,您的宝贵意见对我们很重要,非常感谢!-
问卷链接:地平线算法工具链使用满意度反馈

您好,该报错是由模型输出shape和后处理脚本的输入shape不一致导致的,请先检查推理所用模型的输出shape,对齐后处理脚本的输入。

那具体来说应该修改哪个文件里的参数呢?

想问一下你有修改我们提供的后处理脚本04_detection/03_yolov5x/mapper/postprocess.py中的代码嘛?

需要使ONNX模型输出shape,如下

对齐示例后处理脚本中的

可以参考这篇文章【模型提速】如何在X3pi使用yolov5模型50ms推理 (horizon.cc)