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实例
最新推荐文章于 2022-03-11 16:24:16 发布
本文介绍了一种利用TensorFlow读取、解码并显示JPEG图像的方法,并演示了如何将处理后的图像重新编码为JPEG格式进行保存。通过具体代码实例展示了从文件中加载图像、在会话中解码图像数据、显示图像以及重新编码并保存图像的过程。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.15
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
747

被折叠的 条评论
为什么被折叠?



