You can use tools/deploy/export_model.py to directly convert into onnx format. https://github.com/nhannt69/detectron2/blob/main/tools/deploy/export_model.py
Command: python tools/deploy/export_model.py --config-file [cfg file].yaml --sample-image [image].jpg --output weight --export-method tracing --format onnx MODEL.WEIGHTS [weight].pth MODEL.DEVICE cpu
Good luck.