Conversion of Speech model with PyTorch as a backend into ONNX

Hi,
I am working with ESPNet. My task is to convert ESPNet model(PyTorch banckend) into TFLite for edge deployment.

But, ESPNet is for ASR. I do find a solution which is – convert ESPNet model -> ONNX model -> Tensorflow model -> TFite.

But, I am not succeed. Looking for help.

Please do needful.

looking for response.

Could you explain where you are stuck at the moment and what is not working? :slight_smile:

Hi

I am trying to convert ESPNet (PyTorch as a backend) model into ONNX, but I’m getting error i.e.
TypeError: forward() missing 2 required positional arguments: 'ilens' and 'ys_pad'

I am using this code for conversion.
# Export the trained model to ONNX dummy_input = Variable(torch.randn(83,320)) # [83,320] will be the input to the model torch.onnx.export(model, dummy_input, "model.onnx")

Thanks

Based on the error message it seems that your model expects more inputs to its forward method than the provided tensor.
Could you check, where ilens and ys_pad are used in your model?

Also, Variables are deprecated since PyTorch 0.4 so you can use tensors now. :wink:

Thanks for response.
But this model uses Transformer predefined model.
I am trying to convert this Transformer model into ONNX.

Thanks!