yolov5转onnx:Unsupported ONNX opset version: 17

遇到的问题是无法将yolo训练的pt通过export.py转换成为onnx文件,报错出现的是:
export failure ❌ 0.1s: Unsupported ONNX opset version: 17

解决方案1:
参考的是:ONNX export failure 0.1s unsupported ONNX opset version :17 · Issue #10831 · ultralytics/yolov5 (github.com)降低onnx版本到1.13.1无果。

解决方案2:
参考:(69条消息) yolov5导出onnx模型报错:Unsupported ONNX opset version: 17_李昂的的博客-CSDN博客
ONNX export failure 0.1s unsupported ONNX opset version :17 · Issue #10831 · ultralytics/yolov5 (github.com)
修改了opset的参数 17 14 12 9都有:

export failure ❌ 0.1s: Unsupported ONNX opset version: 14
export failure ❌ 0.4s: Exporting the operator silu to ONNX opset version 12 is not supported. Please open a bug to request ONNX export support for the missing operator.
export failure ❌ 0.7s: Exporting the operator silu to ONNX opset version 9 is not supported. Please open a bug to request ONNX export support for the missing operator.

#opset改成12 出现报错 Exporting the operator silu to ONNX opset version 12 is not supported. Please open a bug to request ONNX export support for the missing operator.
#opset先后改成过17 14 12 9,14和17的报错都是 Unsupported ONNX opset version:
#opset改成9和12就会出现类似onnx不支持silu的情况

参考(69条消息) ONNX: export failure: Exporting the operator silu to ONNX opset version 12 is not suppo_onnx 哪个版本支持silu层_商龙人的博客-CSDN博客 后,修改了

[python安装路径]/site-packages/torch/nn/modules/activation.py 这个文件的394行记录如下:

重写394行
    def forward(self, input: Tensor) -> Tensor:
        # 原始
        # return F.silu(input, inplace=self.inplace)
        # 重写
        return input * torch.sigmoid(input)

成功

你可能感兴趣的:(python,开发语言)