Example #1
0
 def test_default_components(self):
     """Tests that defult components are added when necessary."""
     self._create_metadata()
     stored_metadata = plugin_data_pb2.MeshPluginData(
         version=metadata.get_current_version(), components=0)
     parsed_metadata = metadata.parse_plugin_metadata(
         stored_metadata.SerializeToString())
     self.assertGreater(parsed_metadata.components, 0)
Example #2
0
def create_summary_metadata(
    name,
    display_name,
    content_type,
    components,
    shape,
    description=None,
    json_config=None,
):
    """Creates summary metadata which defined at MeshPluginData proto.

    Arguments:
      name: Original merged (summaries of different types) summary name.
      display_name: The display name used in TensorBoard.
      content_type: Value from MeshPluginData.ContentType enum describing data.
      components: Bitmask representing present parts (vertices, colors, etc.) that
        belong to the summary.
      shape: list of dimensions sizes of the tensor.
      description: The description to show in TensorBoard.
      json_config: A string, JSON-serialized dictionary of ThreeJS classes
        configuration.

    Returns:
      A `summary_pb2.SummaryMetadata` protobuf object.
    """
    # Shape should be at least BxNx3 where B represents the batch dimensions
    # and N - the number of points, each with x,y,z coordinates.
    if len(shape) != 3:
        raise ValueError("Tensor shape should be of shape BxNx3, but got %s." %
                         str(shape))
    mesh_plugin_data = plugin_data_pb2.MeshPluginData(
        version=get_current_version(),
        name=name,
        content_type=content_type,
        components=components,
        shape=shape,
        json_config=json_config,
    )
    content = mesh_plugin_data.SerializeToString()
    return summary_pb2.SummaryMetadata(
        display_name=display_name,  # Will not be used in TensorBoard UI.
        summary_description=description,
        plugin_data=summary_pb2.SummaryMetadata.PluginData(
            plugin_name=PLUGIN_NAME, content=content),
    )