Tensorflow图像读取和显示

Tensorflow图像读取和显示,第1张

Tensorflow图像读取和显示

只是给出一个完整的答案:

filename_queue = tf.train.string_input_producer(['/Users/HANEL/Desktop/tf.png']) #  list of files to readreader = tf.WholeFileReader()key, value = reader.read(filename_queue)my_img = tf.image.depre_png(value) # use png or jpg deprer based on your files.init_op = tf.global_variables_initializer()with tf.Session() as sess:  sess.run(init_op)  # Start populating the filename queue.  coord = tf.train.Coordinator()  threads = tf.train.start_queue_runners(coord=coord)  for i in range(1): #length of your filename list    image = my_img.eval() #here is your image Tensor :)  print(image.shape)  Image.fromarray(np.asarray(image)).show()  coord.request_stop()  coord.join(threads)

或者,如果您有图像目录,则可以通过此Github源文件将其全部添加

@mttk和@ salvador-dali:我希望这是您需要的



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5623889.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存