preview_tiles.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:vae-style-transfer 作者: sunsided 项目源码 文件源码
def main():
    window = 'preview'
    cv2.namedWindow(window)

    tfrecord_file_names = glob(path.join('data', '*.tfrecord.gz'))
    max_reads = 50
    batch_size = 50

    with tf.Graph().as_default() as graph:
        image_batch, type_batch = import_images(tfrecord_file_names, max_reads=max_reads, batch_size=batch_size)

    coord = tf.train.Coordinator()
    with tf.Session(graph=graph) as sess:
        init = tf.group(tf.local_variables_initializer(), tf.global_variables_initializer())
        sess.run(init)

        threads = tf.train.start_queue_runners(sess=sess, coord=coord)

        try:
            while not coord.should_stop():
                Xs = sess.run(image_batch)
                for img in Xs:
                    cv2.imshow(window, img)
                    if (cv2.waitKey(33) & 0xff) == 27:
                        coord.request_stop()
                        break

        except tf.errors.OutOfRangeError:
            print('Read all examples.')
        finally:
            coord.request_stop()
            coord.join(threads)

        cv2.destroyWindow(window)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号