Exporting wav2vec model to ONNX

Hello,

I am trying to export a wav2vec model (cahya/wav2vec2-base-turkish-artificial-cv) to ONNX format with convert_graph_to_onnx.py script provided in transformers repository.

When I try to use these script with this line:
python convert_graph_to_onnx.py --framework pt --model cahya/wav2vec2-base-turkish-artificial-cv exported_model.onnx

I am getting this error:

====== Converting model to ONNX ======
ONNX opset version set to: 11
Loading pipeline (model: cahya/wav2vec2-base-turkish-artificial-cv, tokenizer: cahya/wav2vec2-base-turkish-artificial-cv)
Some weights of the model checkpoint at cahya/wav2vec2-base-turkish-artificial-cv were not used when initializing Wav2Vec2Model: ['lm_head.bias', 'lm_head.weight']
- This IS expected if you are initializing Wav2Vec2Model from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing Wav2Vec2Model from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
Error while converting the model: __init__() got an unexpected keyword argument 'feature_extractor'

All I understand is that this script is not made for specifically wav2vec models. If I am right, how can I convert the wav2vec model to ONNX format?

1 Like

Hi,

Were you able to get this working? I am running into the same issue.

1 Like

Maybe this helps: Converting wav2vec2-base-960h to ONNX report an error while converting · Issue #10004 · huggingface/transformers · GitHub