I stumbled across this repo to convert a PyTorch model to tflite without introducing transpose layers everywhere. After several attempts messing around with TensorFlow, Keras, and PyTorch version combinations I got the code working. Indeed, going through ONNX introduced transpose blocks but converting via Keras using the repo seems to work fine (using change_ordering=True).
I think it might be helpful for others to share the requirements I used and which worked for me:
The whole code is running in a Python=3.6 conda environment
I stumbled across this repo to convert a PyTorch model to tflite without introducing transpose layers everywhere. After several attempts messing around with TensorFlow, Keras, and PyTorch version combinations I got the code working. Indeed, going through ONNX introduced transpose blocks but converting via Keras using the repo seems to work fine (using change_ordering=True).
I think it might be helpful for others to share the requirements I used and which worked for me:
The whole code is running in a Python=3.6 conda environment
Package Version
absl-py 0.9.0 argon2-cffi 20.1.0 astor 0.8.1 attrs 19.3.0 backcall 0.2.0 bleach 3.1.5 certifi 2020.6.20 cffi 1.14.1 decorator 4.4.2 defusedxml 0.6.0 entrypoints 0.3 gast 0.3.3 grpcio 1.30.0 h5py 2.10.0 importlib-metadata 1.7.0 ipykernel 5.3.4 ipython 7.16.1 ipython-genutils 0.2.0 ipywidgets 7.5.1 jedi 0.17.2 Jinja2 2.11.2 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 6.1.6 jupyter-console 6.1.0 jupyter-core 4.6.3 Keras 2.2.0 Keras-Applications 1.0.2 Keras-Preprocessing 1.0.1 Markdown 3.2.2 MarkupSafe 1.1.1 mistune 0.8.4 mock 4.0.2 nbconvert 5.6.1 nbformat 5.0.7 notebook 6.1.0 numpy 1.19.1 onnx 1.7.0 onnx2keras 0.0.22 packaging 20.4 pandocfilters 1.4.2 parso 0.7.1 pexpect 4.8.0 pickleshare 0.7.5 Pillow 7.2.0 pip 20.1.1 prometheus-client 0.8.0 prompt-toolkit 3.0.5 protobuf 3.12.4 ptyprocess 0.6.0 pycparser 2.20 Pygments 2.6.1 pyparsing 2.4.7 pyrsistent 0.16.0 python-dateutil 2.8.1 pytorch2keras 0.2.4 PyYAML 5.3.1 pyzmq 19.0.2 qtconsole 4.7.5 QtPy 1.9.0 scipy 1.5.2 Send2Trash 1.5.0 setuptools 49.2.0.post20200714 six 1.15.0 tensorboard 1.13.1 tensorflow 1.13.1 tensorflow-estimator 1.13.0 termcolor 1.1.0 terminado 0.8.3 testpath 0.4.4 torch 1.1.0 torchvision 0.3.0 tornado 6.0.4 tqdm 4.19.9 traitlets 4.3.3 typing-extensions 3.7.4.2 wcwidth 0.2.5 webencodings 0.5.1 Werkzeug 1.0.1 wheel 0.34.2 widgetsnbextension 3.5.1 zipp 3.1.0