def build_batch_reader(paths_image, batch_size):
"""
"""
file_name_queue = tf.train.string_input_producer(paths_image)
reader_key, reader_val = tf.WholeFileReader().read(file_name_queue)
# decode a raw input image
image = tf.image.decode_jpeg(reader_val, channels=3)
# to float32 and -1.0 ~ +1.0
image = tf.cast(image, dtype=tf.float32) / 127.5 - 1.0
# scale up to increase training data
image = tf.image.resize_images(image, [264, 264])
# crop to 256 x 256 for the model.
# also, a batch need concreate image size
image = tf.random_crop(image, size=[256, 256, 3])
# random horizontal flipping to increase training data
image = tf.image.random_flip_left_right(image)
# create bacth
return tf.train.batch(tensors=[image], batch_size=batch_size)
评论列表
文章目录