Skip to main content

Parsing TensorFlow Lite Models (*.tflite) Easily

Project description

Easily Parse TFLite Models with Python

Build and Test

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

Installation

pip install tensorflow==1.14.0
pip install tflite==1.14.0.post1

It would be better if use a correct version regarding tensorflow, where the mapping is as below. Since 2.0.1, the .post[?] suffix is not needed, such that we can keep this version map simple. If you notice that some version is missing, please consider contribute it! :)

TensorFlow package version tflite package version
1.14.0 1.14.0.post1
1.15.0 1.15.0.post1
1.15.2 1.15.2
2.0.0 2.0.0.post2
2.0.1 2.0.1
2.1.0 2.1.0

Import the package

The package can be imported with easy import or original import, where the difference is how many import you write - no functionality divergence. For supported interfaces, please refer to document page.

Easy Import (Recommanded)

Easy import enables parsing by one single import tflite. This is achieved by importing classes and functions of one submodules into top module directly.

MobileNet parsing example shows how to parse model with import tflite ONLY ONCE.

Original Import

You can use this package just like the newly FlatBuffers generated one (example) to avoid any break of your legacy code.

from tflite.Model import Model

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 classes and functions import of submodules.
    3. Update the versioning in setup.py.
    4. 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.

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

tflite-2.3.0.tar.gz (24.6 kB view hashes)

Uploaded Source

Built Distribution

tflite-2.3.0-py2.py3-none-any.whl (79.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page