def create_metadata(self) -> _metadata_fb.TensorMetadataT: """Creates the input tensor metadata based on the information. Returns: A Flatbuffers Python object of the input metadata. """ tensor_metadata = _metadata_fb.TensorMetadataT() tensor_metadata.name = self.name tensor_metadata.description = self.description # Create min and max values stats = _metadata_fb.StatsT() stats.max = self.max_values stats.min = self.min_values tensor_metadata.stats = stats # Create content properties content = _metadata_fb.ContentT() if self.content_type is _metadata_fb.ContentProperties.FeatureProperties: content.contentProperties = _metadata_fb.FeaturePropertiesT() elif self.content_type is _metadata_fb.ContentProperties.ImageProperties: content.contentProperties = _metadata_fb.ImagePropertiesT() elif self.content_type is ( _metadata_fb.ContentProperties.BoundingBoxProperties): content.contentProperties = _metadata_fb.BoundingBoxPropertiesT() content.contentPropertiesType = self.content_type tensor_metadata.content = content # Create associated files if self.associated_files: tensor_metadata.associatedFiles = [ file.create_metadata() for file in self.associated_files ] return tensor_metadata
def _create_location_metadata( location_md: metadata_info.TensorMd) -> _metadata_fb.TensorMetadataT: """Creates the metadata for the location tensor.""" location_metadata = location_md.create_metadata() content = _metadata_fb.ContentT() content.contentPropertiesType = ( _metadata_fb.ContentProperties.BoundingBoxProperties) properties = _metadata_fb.BoundingBoxPropertiesT() properties.index = list(_BOUNDING_BOX_INDEX) properties.type = _metadata_fb.BoundingBoxType.BOUNDARIES properties.coordinateType = _metadata_fb.CoordinateType.RATIO content.contentProperties = properties content.range = _create_1d_value_range(_CONTENT_VALUE_DIM) location_metadata.content = content return location_metadata