Skip to main content

Convert TensorFlow Lite models to ONNX models

Project description

TFLITE2ONNX - Convert TensorFlow Lite models to ONNX

Build and Test Sanity Coverage

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).

If you'd like to convert a TensorFlow model (frozen graph *.pb, SavedModel or whatever) to ONNX, try tf2onnx. Or, you can firstly convert it to a TFLite (*.tflite) model, and then convert the TFLite model to ONNX.

Usage

Install via pip pip install tflite2onnx. After installation, you may either try either.

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

Contributing

Any contribution is welcome to this tool.

  • If you think something is wrong, 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 discussions if you have any great idea to improve this tool.

Resources

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

tflite2onnx-0.3.0.tar.gz (24.3 kB view hashes)

Uploaded source

Built Distribution

tflite2onnx-0.3.0-py3-none-any.whl (34.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page