def read_my_file_format(filename_queue, resize_shape=None):
"""Sets up part of the pipeline that takes elements from the filename queue
and turns it into a tf.Tensor of a batch of images.
:param filename_queue:
tf.train.string_input_producer object
:param resize_shape:
2 element list defining the shape to resize images to.
"""
reader = tf.TFRecordReader()
key, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example, features={
'image/encoded': tf.FixedLenFeature([], tf.string),
'image/height': tf.FixedLenFeature([], tf.int64),
'image/channels': tf.FixedLenFeature([], tf.int64),
'image/width': tf.FixedLenFeature([], tf.int64)})
example = tf.image.decode_jpeg(features['image/encoded'], 3)
processed_example = preprocessing(example, resize_shape)
return processed_example
评论列表
文章目录