How can I export a transformers model into onnx that not supported with optimum yet

What does OP want?

I want to export the RT-DETR model to the ONNX model.

Which articles OP had read?

I have read Export to ONNX (huggingface.co) and Export a model to ONNX with optimum.exporters.onnx (huggingface.co)

What has OP tried?

I’ve tried exporting RT-DETR transformers model to the ONNX model with ā€˜DummyVisionInputGenerator’ and Custom Config inherited from ā€˜ViTOnnxConfig’

Google Colab

What is the problem?

I met AttributeError: 'RTDetrOnnxConfig' object has no attribute 'keys'
during execution main_export()

I think these people would know.

Or maybe you could try installing the dev version with pip and see if it supports it.

1 Like

I appreciate your kind answeršŸ™‡ā€ā™‚ļø

Thanks to your solution I can get a pre-trained ONNX model of rt-detr😊!!
But I need to export a model from a local path, and can’t use push_to_hub.:cry:

Thank you very much for your thoughtful attentionšŸ™‡ā€ā™‚ļø
I will study more and more from the above links!

Hope you have a peaceful dayšŸ™‡ā€ā™‚ļø!

Nice!

Does that mean it’s too big to upload to the hub?
If it simply can’t connect to the hub, then maybe the token is not yet set up?
You could have a write token issued here and set it up.
Don’t leak the token to anyone else.

Detailed instructions on how to use the hub can be found here.

1 Like

oh It’s because the trained model is not mine alone, so there could be a restriction to sharing it with an open community

(If it was my own project, I’ll push_to_hub for community :cry:)

Oh, that’s how it is.:roll_eyes:
That’s up to each individual.

1 Like

I appreciate your kind responsešŸ™‡ā€ā™‚ļø

Thanks to your teaching, I can grow up one more step
Wish you have a peaceful day!

Hi,

The easiest is to do it as explained in this guide: Convert Transformers to ONNX with Hugging Face Optimum. You can use torch.onnx.export, which is more low-level than Optimum.

Feel free to open an issue on the Optimum repository to add support for RT-DETR.

1 Like

I appreciate your kind answeršŸ™‡ā€ā™‚ļø

Thanks for your thoughtful teaching, I could take a step further🄹

I’ll try the way,torch.onnx.export immediately when I can turn on the computer!

Hope you have a peaceful dayšŸ™‡ā€ā™‚ļø

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.