import matplotlib.pyplot as plt
import tensorflow as tf
path_jpg = 'C:/Users/shibo/Desktop/12.jpg'
image_raw_data = tf.gfile.FastGFile(path_jpg,'rb').read()
with tf.Session() as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
print(img_data.eval())
plt.imshow(img_data.eval())
plt.show()
#img_data = tf.image.convert_image_dtype(img_data,dtype = tf.float32)
encoded_image = tf.image.encode_jpeg(img_data)
with tf.gfile.GFile("C:/Users/shibo/Desktop/15.jpg","wb") as f:
f.write(encoded_image.eval())
tf.gfile.FastGFile实例
最新推荐文章于 2024-04-13 09:37:57 发布