tensorflow:读取tfevents文件(image)

在使用tensorflow训练网络时,为了能方便地检测训练的细节(损失值、变量直方图、图像),一般使用

tf.summary.FileWriter(self.tbdir, sess.graph)来生成event文件,并能利用tensorboard方便看到训练的数据。

但有时需要将数据提取出来,则可用tf.train.summary_iterator()      (ps:tensorboard也有event文件的数据下载)

根据标签读取对应的数据,for example,标量标签cons_bbox_loss和图像ground_truth/image/0:

code:

import tensorflow as tf
import cv2
import os
path='path/events.out.tfevents.*********'
load_num=200
scalars=[]
imgs=[]
try:
    for vs in tf.train.summary_iterator(path):
        for v in vs.summary.value:
            if v.tag=='cons_bbox_loss':
                scalars.append(v.simple_value)
            elif v.tag=='ground_truth/image/0':
                imgs.append(tf.image.decode_jpeg(v.image.encoded_image_string))
        if len(imgs) > load_num:
            break

sess=tf.Session()
imgs=sess.run(imgs[0:load_num])

 

参考链接:https://tensorflow.google.cn/versions/r1.15/api_docs/python/tf/train/summary_iterator

 

完~

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值