def batch_queue_for_training_normal(data_path):
num_channel = argument_sr.options.input_channel
image_height = argument_sr.options.height
image_width = argument_sr.options.width
batch_size = argument_sr.options.batch_size
threads_num = argument_sr.options.num_threads
min_queue_examples = argument_sr.options.min_after_dequeue
filename_queue = tf.train.string_input_producer(get_all_file(path=data_path, endFormat=['jpg']))
file_reader = tf.WholeFileReader()
_, image_file = file_reader.read(filename_queue)
patch = tf.image.decode_jpeg(image_file, 3)
patch = tf.image.convert_image_dtype(patch, dtype=tf.float32)
# patch = RGB_to_Tcrbr_Y(patch)
image_HR8 = tf.random_crop(patch, [image_height, image_width, num_channel])
image_HR4 = tf.image.resize_images(image_HR8, [int(image_height / 2), int(image_width / 2)],
method=tf.image.ResizeMethod.BICUBIC)
image_HR2 = tf.image.resize_images(image_HR8, [int(image_height / 4), int(image_width / 4)],
method=tf.image.ResizeMethod.BICUBIC)
image_LR = tf.image.resize_images(image_HR8, [int(image_height / 8), int(image_width / 8)],
method=tf.image.ResizeMethod.BICUBIC)
low_res_batch, high2_res_batch, high4_res_batch, high8_res_batch = tf.train.shuffle_batch(
[image_LR, image_HR2, image_HR4, image_HR8],
batch_size=batch_size,
num_threads=threads_num,
capacity=min_queue_examples + 3 * batch_size,
min_after_dequeue=min_queue_examples)
return low_res_batch, high2_res_batch, high4_res_batch, high8_res_batch
评论列表
文章目录