open-mmlab / mmdetection3d

OpenMMLab's next-generation platform for general 3D object detection.
https://mmdetection3d.readthedocs.io/en/latest/
Apache License 2.0
5.34k stars 1.55k forks source link

[Feature] Export BevFusion model to onnx or torchscript #3026

Open inzombakura opened 3 months ago

inzombakura commented 3 months ago

What is the feature?

I am looking into whether it is possible to export the BevFusion model to an external format like ONNX or torchscript.

Any other context?

I have been able to load in the model checkpoint (.pth) and use it in the demo (multi_modality_demo.py) but am unable to export the model using torch.export.export or torch.onnx.dynamo_export:

torch.export.export(model, args=(collate_data,))
onnx_program = torch.onnx.dynamo_export(model, collate_data)

and am wondering if their is any documentation or existing ability to export the model in common formats. My goal in completing this is to have a format that can be traced using jit. This will assist in model reusability to other platforms.

Dontrian commented 2 months ago

I have the same problem and to be more specific, the export step fails with the following error:

RuntimeError: Only tuples, lists and Variables are supported as JIT inputs/outputs. Dictionaries and strings are also accepted, but their usage is not recommended. Here, received an input of unsupported type: Det3DDataSample