How can I export a transformers model into onnx that not supported with optimum yet (original) (raw)

August 30, 2024, 1:47am 1

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.

J4BEZ August 30, 2024, 3:11am 3

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.

J4BEZ August 30, 2024, 3:41am 5

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:)

John6666 August 30, 2024, 3:46am 6

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

J4BEZ August 30, 2024, 6:40am 7

I appreciate your kind response🙇‍♂️

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

nielsr August 30, 2024, 10:52am 8

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.

J4BEZ August 30, 2024, 11:25am 9

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🙇‍♂️

system Closed October 8, 2024, 8:24am 10

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