Skip to main content

Convert TensorFlow Lite models to ONNX

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

Highlights

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

  • It's significant to understand the use cases of tflite2onnx, which helps us to decide how to shape tflite2onnx - what features we take as first priority for example. Please help to provide some input in this issue

  • Support of this tool is by best effort - we have very limited resouce, i.e. basically off time effort by the maintainers. So we encourage you to deep dive into your issue and then discuss with us to figure out a solution. Please join to improve!

Installation

Install via pip pip install tflite2onnx.

Or install from source to get latest features (please try out with virtualenv):

  1. Download the repo: git clone https://github.com/jackwish/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.)

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

Contributing

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.

Files for tflite2onnx, version 0.3.2
Filename, size File type Python version Upload date Hashes
Filename, size tflite2onnx-0.3.2-py3-none-any.whl (42.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size tflite2onnx-0.3.2.tar.gz (29.7 kB) File type Source Python version None Upload date Hashes View

Supported by

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