Idea :
Converting onnx to tflite are crucial in many sense. When you want to ship models for android phone or embedded device. Generally, you might not be tensorflow inclined. You may use different framework like pytorch. But when time comes, you’d want to convert your existing pytorch model converted to tflite without retraining model in tensorflow.
In this blogpost, i’ll be citing out the steps. How to do it actually :
- Make sure you have model converted in ONNX.
Process :
- Clone this repo
1 2 3
git clone https://github.com/hiteshhedwig/to-tflite-edge git submodule update --init ./build.sh
-
Convert
.onnx
to.pb
.onnx-tf convert -i "mobilenetv2.onnx" -o "mobilenetv2.pb"
- Finally run command below by providing path to converted PB model `python to_tflite.py “/path/to/pbmodel”
Heads UP :
- If you have an onnx model converted from pytorch model. Make sure you exported the onnx model in torch package <= 1.7
- If you face some errors, try and see if you have non-simplified onnx model version. Simplified onnx version gives trouble
- If you have custom model, and the post is not able to help you. Please know details of your model and try implementing the specific layer for conversion which is longer way to go.
-
Previous
How to learn ALMOST any programming language? -
Next
[Paper review] Single-image camera calibration with model-free distortion correction