Detectron2环境导出onnx
主函数:
detectron2/tools/deploy/export_model.py
命令:
python export_model.py config-file configs/SOLOv2/R50_3x.yaml --output ./outputs --export-method tracing --format onnx MODEL.WEIGHTS SOLOv2_R50_3x/model_0169999.pth MODEL.DEVICE cuda
可能的运行错误:
torch.onnx.errors.UnsupportedOperatorError: Exporting the operator ‘aten::unflatten’ to ONNX opset version 11 is not supported.
修改:
在export_model.py中定位到torch.onnx.export(),将其中的参数opset_version设置为推荐的版本即可(一般是16)