Skip to main content

Easily Parse TFLite Models with Python

Build and Test Download

This tflite package parses TensorFlow Lite (TFLite) models (*.tflite), which are built by TFLite converter. For background, please refer to Introducing TFLite Parser Python Package.

Usage

Install the package and use it like what you build from the TensorFlow codebase. It's recommended to install the version that same as the TensorFlow that generates the TFLite model.

pip install tensorflow==2.3.0
pip install tflite==2.3.0

The raw API of tflite can be found in this documentation. The MobileNet test can serve as a usage example of parsing models.

Enhancements

The generated python package is not friendly to use sometimes. We have introduced several enhancements:

  • Easy import: A single import tflite (example) to replace importing every classes and funtions in tflite (example).
  • Builtin opcode helper: The opcode is encoded as digits which is hard to parse for human. Two APIs added to make it easy to use.

Compatibility Handling

TensorFlow sometimes leaves compability hanlding of the TFLite model to the users. As these are API breaking change that can be easily fixed, we do this in the tflite package.

Contributing Updates

As the operator definition may change across different TensorFlow versions, this package needs to be updated accordingly. If you notice that the package is out of date, please feel free to contribute new versions. This is pretty simple, instructions as below.

  1. Fork the repository, and download it.
  2. Install additional depdendency via pip install -r requirements.txt. And install flatbuffer compiler (you may need to manually build it).
  3. Generate the code for update. Tools have been prepared, there are prompt for actions.
    1. Download schema.fbs for a new version.
    2. Update the builtin operator mapping.
    3. Update the classes and functions import of submodules.
    4. Update the API document.
    5. Update the versioning in __init__.py.
    6. Build and test (simply pytest) around. Don't forget to re-install the newly built tflite package before testing it.
  4. Push your change and open Pull Request.
  5. The maintainer will take the responsibility to upload change to PyPI when merged.

Resources

License

Apache License Version 2.0 as TensorFlow's.

Disclaimer

The schema.fbs is obtained from TensorFlow directly. Maintainer of this package had tried to contact TensorFlow maintainers for licensing issues, but received no reply. Ownership or maintainship is open to transfer or close if there were any issue.

Release files for tflite 2.18.0

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

Source distribution (sdist)

Source distribution for tflite 2.18.0
File Size Uploaded
tflite-2.18.0.tar.gz 49.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tflite 2.18.0
File Interpreter ABI Platform
tflite-2.18.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 202.4 kB

Release files / tflite-2.18.0.tar.gz

Download URL tflite-2.18.0.tar.gz
Size 49.2 kB
Tags Source
SHA-256 checksum
How to use checksums
07e9478e0d0fb4d3082d0ce8e7e6eab4a90a7174412faec7702e24bfcbf4190d
BLAKE2b-256 checksum
How to use checksums
930e186beaed34ce9a740d7add374118b206fac75631c94bb4fa72d63ec32f7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / tflite-2.18.0-py2.py3-none-any.whl

Download URL tflite-2.18.0-py2.py3-none-any.whl
Size 153.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a49a4316530377c597bb272176c12d5d3c4453640118b068c93a8c3cc6c5c2c1
BLAKE2b-256 checksum
How to use checksums
db9bf35d52989cb458a911f1ed4164b37dcf6559237b73c962c09ed0b6cecd4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

2.18.0 This release

2 release files

2.10.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

1 release file

2.1.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.15.2

1 release file

1.15.0

1 release file

1.14.0

1 release file

0.0.2

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