TF Lite Object Detection Model with Metadata

Learn to add metadata to a TF Lite object detection model using TF Lite Metadata Writer API.

Metadata refers to the data that describes other data or information. For DL models, metadata can include the model architecture, input and output details, training details, accuracy metrics, and label files. Let’s use TF Lite Metadata Writer API to include the metadata to an existing object detection TF Lite model.

TF Lite model metadata

TF Lite model metadata is a self-descriptive format that contains information about the model, its inputs and outputs, and associated files.

Note: To enable model inference using either TF Lite Task Library or ML Kit, models should have metadata.

Inference using TF Lite Task Library and ML Kit eliminates the need to interact directly with FlatBuffersFlatBuffers and allows us to use typed objects such as Bitmap to interact with the model. Both contain a set of prebuilt inference tasks that can be easily performed on the model and provide us with tools to integrate models into mobile and edge devices.

TF Lite Metadata Writer API

The TF Lite Metadata Writer API allows us to add metadata to TF Lite models for supported tasks, such as image classifiers, object detectors, image segmenters, natural language classifiers, and audio classifiers. The API also includes utilities for saving and loading metadata files, as well as converting metadata to JSON format for visualization and debugging purposes. The code below shows how to use the TF Lite Metadata Writer API to create metadata for an object detector model and save it to a separate TF Lite file.

Get hands-on with 1400+ tech skills courses.