import tensorflow as tf
import matplotlib.pyplot as plt
def read_image(file_name):
img = tf.read_file(file_name)
print("type(img):", type(img))
img = tf.image.decode_jpeg(img, channels=0)
return img
def main():
with tf.device("/cpu:0"):
img_path = "R1.JPG"
img = read_image(img_path)
with tf.Session() as sess:
image_numpy = sess.run(img)
print(image_numpy)
print(image_numpy.dtype)
print(image_numpy.shape)
plt.imshow(image_numpy)
plt.show()
if __name__ == '__main__':
main()
转载请注明原文地址:https://blackberry.8miu.com/read-40736.html