def read_and_decode_aug(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
# Defaults are not specified since both keys are required.
features={
'image_raw': tf.FixedLenFeature([], tf.string),
})
image = tf.decode_raw(features['image_raw'], tf.uint8)
image = tf.image.random_flip_left_right(tf.reshape(image, [227, 227, 6]))
# Convert from [0, 255] -> [-0.5, 0.5] floats.
image = tf.cast(image, tf.float32) * (1. / 255) - 0.5
image = tf.image.random_brightness(image, 0.01)
image = tf.image.random_contrast(image, 0.95, 1.05)
return tf.split(image, 2, 2) # 3rd dimension two parts
评论列表
文章目录