运行yolov5推理onnx文件时报错:
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: images for the following indices
index: 0 Got: 1 Expected: 16
Please fix either the inputs or the model.
onnxruntime运行出错:
预期获取16,实际获取1
yolov5 .pt文件转.onnx文件
解决方案:
yolov5中export.py导出.onnx文件
parser.add_argument('--include',
将输出模型改为ONNX即可运行export.py自动导出文件
detedt.py文件运行onnx推理报错
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: images for the following indices
index: 0 Got: 1 Expected: 16
Please fix either the inputs or the model.
原因:.pt转.onnx文件时batch_size=16,尺寸太大,修改batch_size=1,重新导出onnx文件,重新运行detect.py成功解决报错: