def read_and_decode(filename_queue, batch_size):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
feature = features()
feature = tf.parse_single_example(
serialized_example,
features = feature,
)
hr_image = tf.decode_raw(feature['hr_image'], tf.uint8)
height = tf.cast(feature['height'], tf.int32)
width = tf.cast(feature['width'], tf.int32)
print(height)
image_shape = tf.stack([128, 128,3 ])
hr_image = tf.reshape(hr_image, image_shape)
hr_image = tf.image.random_flip_left_right(hr_image)
hr_image = tf.image.random_contrast(hr_image, 0.5, 1.3)
hr_images = tf.train.shuffle_batch([hr_image], batch_size = batch_size, capacity = 30,
num_threads = 2,
min_after_dequeue = 10)
return hr_images
评论列表
文章目录