def make_example(filename, image_data, labels, text, height, width):
"""Build an Example proto for an example.
Args:
filename: string, path to an image file, e.g., '/path/to/example.JPG'
image_data: string, JPEG encoding of grayscale image
labels: integer list, identifiers for the ground truth for the network
text: string, unique human-readable, e.g. 'dog'
height: integer, image height in pixels
width: integer, image width in pixels
Returns:
Example proto
"""
example = tf.train.Example(features=tf.train.Features(feature={
'image/encoded': _bytes_feature(tf.compat.as_bytes(image_data)),
'image/labels': _int64_feature(labels),
'image/height': _int64_feature([height]),
'image/width': _int64_feature([width]),
'image/filename': _bytes_feature(tf.compat.as_bytes(filename)),
'text/string': _bytes_feature(tf.compat.as_bytes(text)),
'text/length': _int64_feature([len(text)])
}))
return example
评论列表
文章目录