RuntimeError: Exporting the operator affine_grid_generator to ONNX opset version 9 is not supported.

pth转onnx遇见的坑

RuntimeError: Exporting the operator affine_grid_generator to ONNX opset version 9 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.

RuntimeError: Exporting the operator affine_grid_generator to ONNX opset version 9 is not supported._第1张图片 解决办法:

原torch.onnx.export

torch.onnx.export(STN, input, onnx_path, verbose=True, input_names=input_names, output_names=output_names) # 指定模型的输入,以及onnx的输出路径

改为:

torch.onnx.export(STN, input, onnx_path, export_params=True, verbose=True,
operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK)

 

参考: https://www.wangt.cc/2020/10/runtimeerror-exporting-the-operator-max_unpool2d-to-onnx


 

你可能感兴趣的:(Python,目标检测,opencv,深度学习,pytorch,人工智能)