Writes the metadata and associated files into a TFLite model.
tflite_support.metadata_writers.audio_classifier.metadata_writer.MetadataWriter(
model_buffer: bytearray,
metadata_buffer: Optional[bytearray] = None,
associated_files: Optional[List[str]] = None
)
Args |
model_buffer
|
valid buffer of the model file.
|
metadata_buffer
|
valid buffer of the metadata.
|
associated_files
|
path to the associated files to be populated.
|
Methods
View source
@classmethod
create_from_metadata(
model_buffer: bytearray,
model_metadata: Optional[tflite_support.metadata_schema_py_generated.ModelMetadataT
] = None,
input_metadata: Optional[List[_metadata_fb.TensorMetadataT]] = None,
output_metadata: Optional[List[_metadata_fb.TensorMetadataT]] = None,
associated_files: Optional[List[str]] = None,
input_process_units: Optional[List[_metadata_fb.ProcessUnitT]] = None,
output_process_units: Optional[List[_metadata_fb.ProcessUnitT]] = None
)
Creates MetadataWriter based on the metadata Flatbuffers Python Objects.
Args |
model_buffer
|
valid buffer of the model file.
|
model_metadata
|
general model metadata 1. The subgraph_metadata will be
refreshed with input_metadata and output_metadata.
|
input_metadata
|
a list of metadata of the input tensors 2.
|
output_metadata
|
a list of metadata of the output tensors 3.
|
associated_files
|
path to the associated files to be populated.
|
input_process_units
|
a lits of metadata of the input process units 4.
|
output_process_units
|
a lits of metadata of the output process units 5.
|
Returns |
A MetadataWriter Object.
|
View source
@classmethod
create_from_metadata_info(
model_buffer: bytearray,
general_md: Optional[tflite_support.metadata_writers.metadata_info.GeneralMd
] = None,
input_md: Optional[List[Type[metadata_info.TensorMd]]] = None,
output_md: Optional[List[Type[metadata_info.TensorMd]]] = None,
associated_files: Optional[List[str]] = None
)
Creates MetadataWriter based on the metadata information.
Args |
model_buffer
|
valid buffer of the model file.
|
general_md
|
general information about the model.
|
input_md
|
metadata information of the input tensors.
|
output_md
|
metadata information of the output tensors.
|
associated_files
|
path to the associated files to be populated.
|
Returns |
A MetadataWriter Object.
|
Raises |
ValueError
|
if the tensor names from input_md and output_md do not
match the tensor names read from the model.
|
View source
get_metadata_json() -> str
Gets the generated JSON metadata string before populated into model.
This method returns the metadata buffer before populated into the model.
More fields could be filled by MetadataPopulator, such as
min_parser_version. Use get_populated_metadata_json() if you want to get the
final metadata string.
Returns |
The generated JSON metadata string before populated into model.
|
View source
get_populated_metadata_json() -> str
Gets the generated JSON metadata string after populated into model.
More fields could be filled by MetadataPopulator, such as
min_parser_version. Use get_metadata_json() if you want to get the
original metadata string.
Returns |
The generated JSON metadata string after populated into model.
|
populate
View source
populate() -> bytearray
Populates the metadata and label file to the model file.
Returns |
A new model buffer with the metadata and associated files.
|