开启进程读

import tensorflow as tf
import cifar10.cifar10_input

path = 'beauty/'
filename = ['a.jpg', 'b.jpg', 'c.jpg']
filename = [path+x for x in filename]
print(filename)

#  双线程,一个从文件中读到内存,一个负责运行
with tf.Session() as sess:
    filename_queue = tf.train.string_input_producer(filename, shuffle=False, num_epochs=5)
    #  To use, enqueue filenames in a Queue.  The output of Read will
    #  be a filename (key) and the contents of that file (value).
    reader = tf.WholeFileReader()
    key, value = reader.read(filename_queue)
    tf.local_variables_initializer().run()
    threads = tf.train.start_queue_runners(sess)
    i = 0
    while True:
        i += 1
        image_data = sess.run(value)
        with open('Outs/test_%d.jpg' % i, 'wb') as f:
            f.write(image_data)

猜你喜欢

转载自blog.csdn.net/futangxiang4793/article/details/82772523
今日推荐