Add introduction to the model with metadata format

PiperOrigin-RevId: 360988562
Change-Id: Ia237514735eae86733d8bd27c3dd93f1e7c1d04b
This commit is contained in:
Lu Wang 2021-03-04 13:15:03 -08:00 committed by TensorFlower Gardener
parent 01e576576e
commit 3d2714f0e7
2 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,31 @@ All image models published on
and [TensorFlow Hub](https://tfhub.dev/s?deployment-format=lite) have been
populated with metadata.
## Model with metadata format
<center><img src="../images/convert/model_with_metadata.png" alt="model_with_metadata" width="70%"></center>
<center>Figure 1. TFLite model with metadata and associated files.</center>
Model metadata is defined in
[metadata_schema.fbs](https://github.com/tensorflow/tflite-support/blob/master/tensorflow_lite_support/metadata/metadata_schema.fbs),
a
[FlatBuffer](https://google.github.io/flatbuffers/index.html#flatbuffers_overview)
file. As shown in Figure 1, it is stored in the
[metadata](https://github.com/tensorflow/tensorflow/blob/bd73701871af75539dd2f6d7fdba5660a8298caf/tensorflow/lite/schema/schema.fbs#L1208)
field of the
[TFLite model schema](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/schema/schema.fbs),
under the name, `"TFLITE_METADATA"`. Some models may come with associated files,
such as
[classification label files](https://github.com/tensorflow/examples/blob/dd98bc2b595157c03ac9fa47ac8659bb20aa8bbd/lite/examples/image_classification/android/models/src/main/assets/labels.txt#L1).
These files are concatenated to the end of the original model file as a ZIP
using the ZipFile
["append" mode](https://pymotw.com/2/zipfile/#appending-to-files) (`'a'` mode).
TFLite Interpreter can consume the new file format in the same way as before.
See [Pack the associated files](#pack-the-associated-files) for more
information.
See the instruction below about how to populate, visualize, and read metadata.
## Setup the metadata tools
Before adding metadata to your model, you will need to a Python programming

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB