Beispiel #1
0
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
def _create_segmentation_masks_metadata(
        masks_md: metadata_info.TensorMd) -> _metadata_fb.TensorMetadataT:
    """Creates the metadata for the segmentation masks tensor."""
    masks_metadata = masks_md.create_metadata()

    # Create tensor content information.
    content = _metadata_fb.ContentT()
    content.contentProperties = _metadata_fb.ImagePropertiesT()
    content.contentProperties.colorSpace = _metadata_fb.ColorSpaceType.GRAYSCALE
    content.contentPropertiesType = _metadata_fb.ContentProperties.ImageProperties
    # Add the content range. See
    # https://github.com/tensorflow/tflite-support/blob/ace5d3f3ce44c5f77c70284fa9c5a4e3f2f92abb/tensorflow_lite_support/metadata/metadata_schema.fbs#L285-L347
    dim_range = _metadata_fb.ValueRangeT()
    dim_range.min = _CONTENT_DIM_MIN
    dim_range.max = _CONTENT_DIM_MAX
    content.range = dim_range
    masks_metadata.content = content

    return masks_metadata
Beispiel #3
0
def _create_metadata_with_value_range(
        tensor_md: metadata_info.TensorMd) -> _metadata_fb.TensorMetadataT:
    """Creates tensor metadata with extra value range information."""
    tensor_metadata = tensor_md.create_metadata()
    tensor_metadata.content.range = _create_1d_value_range(_CONTENT_VALUE_DIM)
    return tensor_metadata