def setup_reader(self, image_paths, image_shape, num_concurrent, batch_size):
# Path queue is list of image paths which will further be processed by another queue
num_images = len(image_paths)
indices = tf.range(0, num_images, 1)
self.path_queue = tf.FIFOQueue(capacity=num_images, dtypes=[tf.int32, tf.string], name='path_queue')
self.enqueue_path = self.path_queue.enqueue_many([indices, image_paths])
self.close_path = self.path_queue.close()
processed_queue = tf.FIFOQueue(capacity=num_images,
dtypes=[tf.int32, tf.float32],
shapes=[(), image_shape],
name='processed_queue')
(idx, processed_image) = self.process()
enqueue_process = processed_queue.enqueue([idx, processed_image])
self.dequeue_batch = processed_queue.dequeue_many(batch_size)
self.queue_runner = tf.train.QueueRunner(processed_queue, [enqueue_process] * num_concurrent)
评论列表
文章目录