Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhenhuaw-me/tflite2onnx
Convert TensorFlow Lite models (*.tflite) to ONNX.
https://github.com/zhenhuaw-me/tflite2onnx
model-converter onnx pip tensorflow tflite
Last synced: 9 days ago
JSON representation
Convert TensorFlow Lite models (*.tflite) to ONNX.
- Host: GitHub
- URL: https://github.com/zhenhuaw-me/tflite2onnx
- Owner: zhenhuaw-me
- License: apache-2.0
- Created: 2020-03-02T12:44:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T03:03:12.000Z (12 months ago)
- Last Synced: 2024-10-23T04:52:25.450Z (17 days ago)
- Topics: model-converter, onnx, pip, tensorflow, tflite
- Language: Python
- Homepage: https://zhenhuaw.me/tflite2onnx
- Size: 137 MB
- Stars: 149
- Watchers: 10
- Forks: 26
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tflite2onnx - Convert TensorFlow Lite models to ONNX
====================================================[![Build and Test](https://github.com/zhenhuaw-me/tflite2onnx/workflows/Build%20and%20Test/badge.svg)](https://github.com/zhenhuaw-me/tflite2onnx/actions?query=workflow%3A%22Build+and+Test%22)
[![Sanity](https://github.com/zhenhuaw-me/tflite2onnx/workflows/Sanity/badge.svg)](https://github.com/zhenhuaw-me/tflite2onnx/actions?query=workflow%3ASanity)
[![Coverage](https://codecov.io/gh/zhenhuaw-me/tflite2onnx/branch/master/graph/badge.svg)](https://codecov.io/gh/zhenhuaw-me/tflite2onnx)
[![Download](https://img.shields.io/pypi/dm/tflite2onnx)](https://img.shields.io/pypi/dm/tflite2onnx)`tflite2onnx` converts TensorFlow Lite (TFLite) models (`*.tflite`) to ONNX models (`*.onnx`),
with data layout and quantization semantic properly handled (check the [introduction blog][intro] for detail).If you'd like to convert a TensorFlow model (frozen graph `*.pb`, `SavedModel`
or whatever) to ONNX, try [`tf2onnx`](https://github.com/onnx/tensorflow-onnx).
Or, you can firstly [convert][tf2tflite] it to a TFLite (`*.tflite`) model,
and then convert the TFLite model to ONNX.## Call for Contribution
Currently we have [14 open issues](https://github.com/zhenhuaw-me/tflite2onnx/issues).
I am sorry that I don't have more bandwidth to work on them.
*Please help to contribute to this project!* See [Contributing](#contributing) below.Started from the beginning, I have written [docs](#documentation) to help you ramp up this project.
Therefore I am not the critical path of this project.Microsoft has implemented another _TensorFlow Lite to ONNX model converter_ in `tf2onnx`
[at Feb 2021](https://github.com/onnx/sigs/blob/master/converters/meetings/019-20210212.md)
(we open sourced `tflite2onnx` in May 2020). `tf2onnx` seems to able to convert Quantization
just like us, and it seems able to convert RNN networks which we are not supported yet.
Yet, due to the architecture, I think it's non-trivial to fix a bug, which means that,
`tflite2onnx` is a rather better choice if you are blocked and don't wait for a fix from the maintainer.## Installation
Install via [pip][pypi] `pip install tflite2onnx`.
Or install from source to get latest features (please try out with [virtualenv](https://virtualenv.pypa.io)):
1. Download the repo: `git clone https://github.com/zhenhuaw-me/tflite2onnx.git && cd tflite2onnx`
2. Build the package: `./scripts/build-wheel.sh`
3. 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.)```sh
export PYTHONPATH=$(pwd):${PYTHONPATH}
```## Usage
### Python Interface
```py
import tflite2onnxtflite_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](https://github.com/zhenhuaw-me/tflite2onnx/blob/master/tests/test_explicit_layout.py).### Command Line
```sh
tflite2onnx /path/to/original/tflite/model /path/to/save/converted/onnx/model
```## Documentation
* [FAQ](docs/faq.md)
* [Release note](docs/release-notes.md)
* [Contribution guide](docs/contribution-guide.md)
* [Introduction blog - the background, design and implementation][intro]
* [How to enable a new operator](docs/how-to-enable-new-operator.md)
* [Data layout semantic](docs/data-layout-semantic.md)## Contributing
* If something seems wrong to you, [report bugs](https://github.com/zhenhuaw-me/tflite2onnx/issues/new?assignees=&labels=bug&template=bug-report.md&title=).
* If some operators are not supported yet, you may [request a new operator](https://github.com/zhenhuaw-me/tflite2onnx/issues/new?assignees=&labels=operator%2C+help+wanted&template=request-operator.md&title=Operator+request%3A).
* It would be great if you can help to enable new operators, please join us with [How to enable a new operator](docs/how-to-enable-new-operator.md).
* Feel free to open any other related discussions.Check [contribution guide](docs/contribution-guide.md) for more.
## License
Apache License Version 2.0.
[intro]: https://zhenhuaw.me/blog/2020/Convert-TensorFlow-Lite-models-to-ONNX.html
[pypi]: https://pypi.org/project/tflite2onnx
[github]: https://github.com/zhenhuaw-me/tflite2onnx
[tf2tflite]: https://www.tensorflow.org/lite/convert