Prototype of TFLite model metadata.
PiperOrigin-RevId: 263053990
This commit is contained in:
parent
12165a4acf
commit
56bd72ef65
@ -79,6 +79,12 @@ flatbuffer_cc_library(
|
||||
out_prefix = "reflection/",
|
||||
)
|
||||
|
||||
# Generic schema for model metadata.
|
||||
flatbuffer_cc_library(
|
||||
name = "metadata_schema_fbs",
|
||||
srcs = ["metadata_schema.fbs"],
|
||||
)
|
||||
|
||||
# Schema test to make sure we don't introduce backward incompatible changes
|
||||
# to schemas.
|
||||
cc_test(
|
||||
|
160
tensorflow/lite/schema/metadata_schema.fbs
Normal file
160
tensorflow/lite/schema/metadata_schema.fbs
Normal file
@ -0,0 +1,160 @@
|
||||
// Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace tflite;
|
||||
|
||||
// WARNING: This file contains experimental interface and is subject to change.
|
||||
|
||||
// This corresponds to the version.
|
||||
file_identifier "TFLM";
|
||||
// File extension of any written files.
|
||||
file_extension "tflitemeta";
|
||||
|
||||
enum AssociatedFileType : byte {
|
||||
UNKNOWN = 0,
|
||||
// Files such as readme.txt
|
||||
DESCRIPTIONS = 1,
|
||||
// Contains class labels used in classification. For example, the label files
|
||||
// in image classification.
|
||||
LABELS = 2,
|
||||
// The vocab files used in NLP.
|
||||
VOCABULARY = 3,
|
||||
// Files that translate between languages, for example, the language resource
|
||||
// file in Android.
|
||||
LOCALIZATION = 4,
|
||||
}
|
||||
|
||||
table AssociatedFile {
|
||||
// Name of this file.
|
||||
name:string;
|
||||
|
||||
// A description of what the file is.
|
||||
description:string;
|
||||
|
||||
// Type of the associated file. There may be special pre/post processing for
|
||||
// some types. For example in image classification, a label file of the output
|
||||
// will be used to convert object index into string.
|
||||
type:AssociatedFileType;
|
||||
}
|
||||
|
||||
// The type of content that a tensor may represent.
|
||||
enum ContentType : byte {
|
||||
UNKNOWN = 0,
|
||||
IMAGE = 1,
|
||||
VIDEO = 2,
|
||||
TEXT = 3,
|
||||
AUDIO = 4,
|
||||
FEATURE = 5,
|
||||
}
|
||||
|
||||
// The type of color space of an image.
|
||||
enum ColorSpaceType : byte {
|
||||
UNKNOWN = 0,
|
||||
RGB = 1,
|
||||
BGR = 2,
|
||||
YUV = 3,
|
||||
HSV = 4,
|
||||
GRAYSCALE = 5,
|
||||
}
|
||||
|
||||
table ImageSize {
|
||||
width:uint;
|
||||
height:uint;
|
||||
}
|
||||
|
||||
table ImageProperties {
|
||||
// The color space of the image.
|
||||
color_space:ColorSpaceType;
|
||||
|
||||
// Indicates the default value of image width and height if the tensor shape
|
||||
// is dynamic. For fixed-size tensor, this size will be consistent with the
|
||||
// expected size.
|
||||
default_size:ImageSize;
|
||||
}
|
||||
|
||||
// Detailed information of an input or output tensor.
|
||||
table TensorMetadata {
|
||||
// Name of the tensor.
|
||||
name:string;
|
||||
|
||||
// A description of the tensor.
|
||||
description:string;
|
||||
|
||||
// The type of content that this tensor represents.
|
||||
content_type:ContentType;
|
||||
|
||||
// Values are normailzed per-channelly by (x - mean) / std.
|
||||
// If there is only one value in mean and std, we'll propogate the value to
|
||||
// all channels.
|
||||
// Mean of the possible values used in normalization.
|
||||
mean:[float];
|
||||
|
||||
// Standard dev. of the possible values used in normalization.
|
||||
std:[float];
|
||||
|
||||
// Properties that define an image. The section is used when the Content Type
|
||||
// is specified as image.
|
||||
image_properties:ImageProperties;
|
||||
|
||||
// A list of associated files of this tensor.
|
||||
associated_files:[AssociatedFile];
|
||||
}
|
||||
|
||||
table SubGraphMetadata {
|
||||
// Name of the subgraph.
|
||||
name:string;
|
||||
|
||||
// A description explains details about what the subgraph does.
|
||||
description:string;
|
||||
|
||||
// Metadata of all input tensors used in this subgraph.
|
||||
input_tensor_metadata:[TensorMetadata];
|
||||
|
||||
// Metadata of all output tensors used in this subgraph.
|
||||
output_tensor_metadata:[TensorMetadata];
|
||||
|
||||
// A list of associated files of this subgraph.
|
||||
associated_files:[AssociatedFile];
|
||||
}
|
||||
|
||||
table ModelMetadata {
|
||||
// Name of the model.
|
||||
name:string;
|
||||
|
||||
// This is duplicated from the Model description in schema.
|
||||
// description:string;
|
||||
|
||||
// Version of the model that specified by model creators.
|
||||
version:string;
|
||||
|
||||
// Noted that, the minimum required TFLite runtime version that the model is
|
||||
// compatible with, has already been added as a metadata entry in tflite
|
||||
// schema. We'll decide later if we want to move it here, and keep it with
|
||||
// other metadata entries.
|
||||
|
||||
// Metadata of all the subgraphs of the model. The 0th is assumed to be the
|
||||
// main subgraph.
|
||||
subgraph_metadata:[SubGraphMetadata];
|
||||
|
||||
// The person who creates this model.
|
||||
author:string;
|
||||
|
||||
// Licenses that may apply to this model.
|
||||
license:string;
|
||||
|
||||
// A list of associated files of this model.
|
||||
associated_files:[AssociatedFile];
|
||||
}
|
||||
|
||||
root_type ModelMetadata;
|
Loading…
Reference in New Issue
Block a user