I want to convert a model into onnx But when I import caffe2_export for exporting model to onnx I get this error
from detectron2.export import caffe2_export
ERROR import onnx.optimizer ModuleNotFoundError: No module named 'onnx.optimizer'
I want to convert a model into onnx But when I import caffe2_export for exporting model to onnx I get this error
from detectron2.export import caffe2_export
ERROR import onnx.optimizer ModuleNotFoundError: No module named 'onnx.optimizer'
It is because onnxoptimizer has been removed since onnx version 1.9.
If you really do need to use it, you can install onnx version 1.8.
pip install onnx==1.8.1
NOTE: I do not recommend this method.
If you really want to export a model into an onnx format, I'd recommend you to use export_model.py.
For anyone else that comes across this, exporting a Detectron2 model to ONNX format is not straightforward at all. The export includes operations which require Caffe2, and these then need to be replaced.
Someone's managed it here, but I can't replicate it https://github.com/NVIDIA/TensorRT/issues/2546
MMDetection is very similar to Detectron2, but exports are much better supported.