Parsing TensorFlow Lite Models (*.tflite) Easily
Archived. The repository is read-only: no more fixes or releases will come.
pip install tfliteEasily Parse TFLite Models with Python
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 intflite(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.
tflite.opcode2name(): get the type name of given opcode.tflite.BUILTIN_OPCODE2NAME: a dict that maps the opcode to name of all the builtin operators.
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 package.