Convert TensorFlow Lite models to ONNX
Project description
tflite2onnx - Convert TensorFlow Lite models to ONNX
tflite2onnx converts TensorFlow Lite (TFLite) models (*.tflite) to ONNX models (*.onnx),
with data layout and quantization semantic properly handled (check the introduction blog for detail).
Highlights
-
If you'd like to convert a TensorFlow model (frozen graph
*.pb,SavedModelor whatever) to ONNX, trytf2onnx. Or, you can firstly convert it to a TFLite (*.tflite) model, and then convert the TFLite model to ONNX. -
Microsoft has implemented another TensorFlow Lite to ONNX model converter in
tf2onnxat Feb 2021 (we open sourcedtflite2onnxin May 2020).tf2onnxseems to able to convert Quantization just like us, and it seems able to convert RNN networks which we are not supported yet. Please trytf2onnx --tfliteiftflite2onnxmissing any functionality.
Installation
Install via pip pip install tflite2onnx.
Or install from source to get latest features (please try out with virtualenv):
- Download the repo:
git clone https://github.com/zhenhuaw-me/tflite2onnx.git && cd tflite2onnx - Build the package:
./scripts/build-wheel.sh - Install the built package:
pip install assets/dist/tflite2onnx-*.whl
Or you can just add the code tree to your $PYTHONPATH.
(Command line tool is not avaiable in this mode.)
export PYTHONPATH=$(pwd):${PYTHONPATH}
Usage
Python Interface
import tflite2onnx
tflite_path = '/path/to/original/tflite/model'
onnx_path = '/path/to/save/converted/onnx/model'
tflite2onnx.convert(tflite_path, onnx_path)
tflite2onnx now supports explicit layout, check the
test example.
Command Line
tflite2onnx /path/to/original/tflite/model /path/to/save/converted/onnx/model
Documentation
- FAQ
- Release note
- Contribution guide
- Introduction blog - the background, design and implementation
- How to enable a new operator
- Data layout semantic
Contributing
- If something seems wrong to you, report bugs.
- If some operators are not supported yet, you may request a new operator.
- It would be great if you can help to enable new operators, please join us with How to enable a new operator.
- Feel free to open any other related discussions.
Check contribution guide for more.
License
Apache License Version 2.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tflite2onnx-0.4.1.tar.gz.
File metadata
- Download URL: tflite2onnx-0.4.1.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a17d18398a87e40bf25df7c190b6fa9533dab3812431690e858f87ee2b697022
|
|
| MD5 |
dc4d87a9fd6c3564de5ea6547a3f3e96
|
|
| BLAKE2b-256 |
829047beb443f16ce9264213bec1776fda2c168367ebc992a88039df19f87023
|
File details
Details for the file tflite2onnx-0.4.1-py3-none-any.whl.
File metadata
- Download URL: tflite2onnx-0.4.1-py3-none-any.whl
- Upload date:
- Size: 42.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef310782d970220cef8ba407bdbcdf4c18f787a176fc16325ef7da08df3c503a
|
|
| MD5 |
3fb980d61a832aa62dddbad8093aa3a9
|
|
| BLAKE2b-256 |
91d221041386acdfbe76bfbaaf46b799e3af3a1ae69f3c9fe633c78273e7eacd
|