def tf_ops(self, capacity=32):
im_path, label_path = tf.train.slice_input_producer(
[tf.constant(self.images), tf.constant(self.labels)],
capacity=capacity,
shuffle=self.shuffle)
im_shape = [1024, 1024 + self.overlap, 3]
label_shape = [1024, 1024 + self.overlap]
queue = tf.FIFOQueue(capacity, [tf.float32, tf.int32],
shapes=[im_shape, label_shape])
im = tf.read_file(im_path)
im = tf.image.decode_image(im, channels=3)
im = tf.cast(im, tf.float32)
left_im = im[:, :1024 + self.overlap, :]
right_im = im[:, 1024 - self.overlap:, :]
left_im.set_shape(im_shape)
right_im.set_shape(im_shape)
label = tf.read_file(label_path)
label = tf.image.decode_image(label, channels=1)
label = label[:, :, 0]
label = tf.cast(label, tf.int32)
label_pad = tf.ones([1024, self.overlap], dtype=tf.int32) * 255
left_label = tf.concat([label[:, :1024], label_pad], 1)
right_label = tf.concat([label_pad, label[:, 1024:]], 1)
left_label.set_shape(label_shape)
right_label.set_shape(label_shape)
ims = tf.stack([left_im, right_im], 0)
labels = tf.stack([left_label, right_label], 0)
enqueue_op = queue.enqueue_many([ims, labels])
qr = tf.train.QueueRunner(queue, [enqueue_op])
tf.train.add_queue_runner(qr)
return queue.dequeue()
cityscapes.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录