A package to parse TFLite models (*.tflite)
Project description
Python Package to Parse TFLite Models Easily
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
. The module and submodules are listed in the document page.
Installation
This package can be installed via pip, and is versioning similar to TensorFlow package. And the version mapping is as below.
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 |
It would be better if you use a correct version, such as:
pip install tensorflow==1.14.0
pip install tflite==1.14.0.post1
Easy Import
With this package, you may avoid too many imports per submodules. 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)
.
import tflite
# use tflite.Model
The MobileNet parsing example shows how to parse model with import tflite
ONLY ONCE. On contrary, the original generated package needs to import every classes by hand (see this) which is pretty annoying.
In addition, you can use this package just like the newly FlatBuffers generated one (example):
from tflite.Model import Model
# use Model
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 steps:
- Download the
schema.fbs
change of a version. - Update the classes and functions import of submodules.
- Update the versioning in setup.py.
- Build and Test around.
- 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
- GitHub page of this package.
- Module list of this package.
- Converting TensorFlow model to TFLite model.
- Another package has already been used in TVM.
License
Apache License Version 2.0 as TensorFlow's.
Disclaimer
The schema.fbs
is obtained from TensorFlow directly, which could be property of Google. Maintainer of this package had tried to contact TensorFlow maintainers for licensing issues, but received no reply. Ownership or maitainship of this package is open to transfer or close if there were any issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for tflite-2.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 496445455b436879643e0c45c948211d91ae4be66aeb5d534908696b72dce081 |
|
MD5 | 03fb924ac5f988fab3e7ea8a9ccd8b86 |
|
BLAKE2b-256 | 3a6372632334b11ca609804170f4ff9476a815b8be5439e77428c9dc6e77ba94 |