tf读取图片,matplotlib可视化

代码:

"""
使用tf读取图片
"""


import tensorflow as tf
import matplotlib.pyplot as plt


image_raw = tf.gfile.FastGFile(r'C:\Users\Administrator\Desktop\meatwice\meatwice\01newCognition\reinforcement_learning\new_test_tensorflow\picture_set\b023260d27ab8087b5b7d73b837094d.png', \
                     'rb').read()

img = tf.image.decode_jpeg(image_raw)

with tf.Session() as sess:
    img1 = img.eval()
    # print(img1)
    print(img1.shape)

plt.figure(1)
plt.imshow(img1)
plt.show()

 

显示:

 

转载于:https://www.cnblogs.com/zrmw/p/11589503.html