Parsing TensorFlow Lite Models (*.tflite) Easily
Project description
Easily Parse TFLite Models with Python
This tflite
package parses TensorFlow Lite (TFLite) models (*.tflite
), which are built by TFLite converter with the help of FlatBuffers. For background, please refer to Introducing TFLite Parser Python Package.
Installation
Simply install via pip. This package requires flatbuffers
and numpy
which should be installed automatically.
pip install tensorflow==1.14.0
pip install tflite==1.14.0.post1
It would be better if you use a correct version, where the mapping is as below. Since 2.0.1
, we don't need .post?
suffix, so 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 |
Usage
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 developers using parsing functionality wich 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
# use Model
The original generated package needs to import every classes by hand (see this) which is pretty annoying.
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.
- Fork the repository, and download it.
- Install additional depdendency via
pip install -r requirements.txt
- Generate the code for update. Tools have been prepared, there are prompt for actions.
- Push your change and open Pull Request.
- 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
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.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1be887e4390b8e97a18fbb7e4d6fddee4c4882390d22f8edca18dfba2902bed7 |
|
MD5 | 2b30f548d7246dae74a911c02015f0fe |
|
BLAKE2b-256 | 9e83c3ad8f1b31b432a762e418c415e25604d80e26b1444349aeba8cec21d751 |