读取机制有四种方法方法一直接读取图片
直接写代码
# tensorflow read picture读取图片机制
import tensorflow as tf
with tf.Session() as sess :
filename = [ 'C0.jpg', 'C1.jpg' ,'C2.jpg']
filename_queue =tf.train.string_input_producer(filename ,shuffle =False ,num_epochs = 5)
reader = tf.WholeFileReader()
key , value =reader.read(filename_queue)
tf.local_variables_initializer().run()
threads = tf.train.start_queue_runners(sess= sess)
i = 0
while True :
i+= 1
image_data = sess.run(value)
with open('tfIO/test_%d.jpg' % i, 'wb') as f :
f.write (image_data)
会跳出OutOfRangeError (see above for traceback): FIFOQueue '_3_input_producer_1' is closed and has insufficient elements (requested 1, current size 0)
这是遇到结尾标志,正常,在相应文件中已经读取完毕