def caption_example(image):
  """Convert image caption data into an Example proto.

  Args:
    image: A ImageMetadata instance.

  Returns:
    example: An Example proto with serialized tensor data.
  """
  # Collect image object information from metadata.
  image_features, positions = read_object(image.objects, image.image_id)

  # Serialize multi-dimensional tensor data.
  captions_proto = tf.make_tensor_proto(np.array(image.captions))
  features_proto = tf.make_tensor_proto(image_features)
  positions_proto = tf.make_tensor_proto(positions)

  # Create final features dict.
  features = dict(
      image_id=int64_feature(image.image_id),
      captions=bytes_feature(captions_proto.SerializeToString()),
      object_features=bytes_feature(features_proto.SerializeToString()),
      object_positions=bytes_feature(positions_proto.SerializeToString()))
  return tf.train.Example(features=tf.train.Features(feature=features))
Convert image caption data into an Example proto.

  Args:
    image: A ImageMetadata instance.

  Returns:
    example: An Example proto with serialized tensor data.
  
language/capwap/utils/io_utils.py