Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting wav2vec2-base-960h to ONNX report an error while converting #10004

Closed
Denovitz opened this issue Feb 4, 2021 · 7 comments
Closed

Comments

@Denovitz
Copy link

Denovitz commented Feb 4, 2021

First of all, I want to say thanks to @patrickvonplaten for the work done in adding the model. Great job!

I tried to convert the model to ONNX but got an error, do you have any ideas how to fix it?

What I did:
python -m transformers.convert_graph_to_onnx --framework pt --model facebook/wav2vec2-base-960h wav2vec2-base-960h.onnx

But got an error:

ONNX opset version set to: 11
Loading pipeline (model: facebook/wav2vec2-base-960h, tokenizer: facebook/wav2vec2-base-960h)
Using framework PyTorch: 1.7.0
Error while converting the model: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length.
@mironnn
Copy link

mironnn commented Feb 9, 2021

Also interested in this question!

@patrickvonplaten
Copy link
Contributor

Hmm, Wav2Vec2 is still a very recent addition and I don't have a good idea on an ETA for full ONNX support. However, I think your error above is due to the input that's passed to Wav2Vec2Tokenizer being a string instead of a speech input. So in order to make the conversion work, you will have to tweak the script convert_graph_to_onnx yourself a bit for Wav2Vec2 - I think the only different should be that instead of passing it "This is a sample output" you should pass it a 1D float array.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@OthmaneJ
Copy link

Hi!
very interested in this question! did anyone managed to make it work ?

@patrickvonplaten
Copy link
Contributor

Hey @OthmaneJ,

Think @ccoreilly managed to get it to work here: https://github.com/ccoreilly/wav2vec2-service/blob/master/convert_torch_to_onnx.py

@OthmaneJ
Copy link

@patrickvonplaten thanks! 👌

@marziye-A
Copy link

hi @patrickvonplaten
is there any way to transform mms asr model to onnx?
if yes, how?
thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants