Skip to main content

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.

  • Microsoft has implemented another TensorFlow Lite to ONNX model converter in tf2onnx at Feb 2021 (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. Please try tf2onnx --tflite if tflite2onnx missing any functionality.

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

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.

Metadata

Release files for tflite2onnx 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tflite2onnx 0.4.1
File Size Uploaded Provenance Actions
tflite2onnx-0.4.1.tar.gz 29.3 kB Without provenance Details for tflite2onnx-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tflite2onnx 0.4.1
File Interpreter ABI Platform Actions
tflite2onnx-0.4.1-py3-none-any.whl Python 3 none any Details for tflite2onnx-0.4.1-py3-none-any.whl

Total release size: 71.4 kB

Release files / tflite2onnx-0.4.1.tar.gz

Download URL tflite2onnx-0.4.1.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a17d18398a87e40bf25df7c190b6fa9533dab3812431690e858f87ee2b697022
BLAKE2b-256 checksum
How to use checksums
829047beb443f16ce9264213bec1776fda2c168367ebc992a88039df19f87023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.14

Release files / tflite2onnx-0.4.1-py3-none-any.whl

Download URL tflite2onnx-0.4.1-py3-none-any.whl
Size 42.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef310782d970220cef8ba407bdbcdf4c18f787a176fc16325ef7da08df3c503a
BLAKE2b-256 checksum
How to use checksums
91d221041386acdfbe76bfbaaf46b799e3af3a1ae69f3c9fe633c78273e7eacd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.14

Security for tflite2onnx 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page