MachineLP的Github(欢迎follow):https://github.com/MachineLP
下面代码是使用tensorboard显示图片:
#coding=utf-8
import tensorflow as tf
# 获取图片数据
file = open('lp.jpg', 'rb')
data = file.read()
file.close()
# 图片处理
image = tf.image.decode_jpeg(data, channels=3)
image = tf.expand_dims(image, 0)
# 添加到日志中
sess = tf.Session()
writer = tf.summary.FileWriter('logs')
summary_op = tf.summary.image("image1", image)
# 运行并写入日志
summary = sess.run(summary_op)
writer.add_summary(summary)
# 关闭
writer.close()
sess.close()
在终端输入: