Skip to main content

A package to parse TFLite models (*.tflite)

Project description

The python package to parse TFLite models

TFLite models (*.tflite) are in FlatBuffers format. This tflite package is built to parse the TFLite models from the schema.fbs of TensorFlow.

Usage

Using this package, you can parse the TFLite models (*tflite) in Python. One target of this package is to let people use it as the one originally built from schema.fbs.

Installation

This package can be installed via pip, and is is versioning with TensorFlow package, which means a tflite==1.14.0 is generated from tensorflow==1.14.0. Versions after 1.14.0 is maintained.

So, if you have a TFLite model generated from TensorFlow 1.14.0, install the dedicated TFLite package by

pip install tflite==1.14.0

That's it!

For the released version, check PyPI or GitHub.

The compatibility across different versions is guaranteed. It's recommanded to use the correct version.

Use the package

Basically, the usage styles include:

  • Easy import avoids too many imports per submodules (example): import tflite. This is also the recommanded way to use this package.
  • Nested import tflite modules tflite.tflite as it is the originally built one (example): from tflite.tflite.Model import Model. This is as a workaround when encountering bug in easy import.

The easy import imports the classes and functions of one submodules into top module directly, e.g. import the {package}.{submodules}.{class or function} as {package}.{class or function}. For example, when building the Model object, tflite.Model.GetRootAsModel(buf, 0) should be used rather than tflite.Model.Model.GetRootAsModel(buf, 0). This should be much easy to use. Look into the tests for more examples.

Besides, if you prefer the very original style of the FlatBuffers generated package, try this one.

Development

Package users can safely ignore this part.

To develop this package, additional depdendency can be installed via pip install -r requirements.txt.

The tools directory holds some scripts to update the package to corresponding TensorFlow version. There are three steps currently:

  1. Download the schema.fbs change of a version.
  2. Update the classes and functions import of submodules.
  3. Update the versioning in setup.py.
  4. Build and Test around.
  5. Upload the package to PyPI.

Features could be added to make the parsing easy in the future.

Don't forget to re-install the newly built tflite package before testing it. You may also try source tools/source-me.sh rather than the annoying build and install process in development.

Resources

License

Apache License Version 2.0 as TensorFlow's.

Disclaimer

The schema.fbs is obtained from TensorFlow directly, which could be property of Google. Maitainer of this package has tried to [contact](assets/[TFLite] Propose to maintain a PyPI package for TFLite model parsing.eml) one of the TensorFlow maitainers for legal or permission issues, but receiving no reply. Ownership or maitainship of this package is open to transfer or close if there were any issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tflite-2.0.0-py2.py3-none-any.whl (79.5 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