pwc中tensorboard显示图片

在Tensorboard中显示图片的功能可以在visualize.py模块实现。通过创建OptFlowTBLogger实例分别用于训练(train)和验证(val)数据。设置图像的长宽比例,使用subplot布局绘制图像,并保存到指定的tensorboard目录下。图片的保存和解析涉及到文件路径操作,以及使用特定的函数将图像数据上传到tensorboard,其中tag对应于变量名称。
摘要由CSDN通过智能技术生成

tensorboard保存图片

图片显示功能在visualize.py这个文件夹中,

 self.writer这个有两个,一个对应train,一个对应val

self.tb_train = OptFlowTBLogger(LOG_DIR, 'train')#'./pwcnet-sm-6-2-multisteps-chairsthingsmix/'

self.tb_val = OptFlowTBLogger(LOG_DIR, 'val')

def plot_img_pairs_w_flows(
        img_pairs,
        flow_pyrs=None,
        num_lvls=0,
        flow_preds=None,
        flow_gts=None,
        titles=None,
        info=None,
        flow_mag_max=None):
    """Plot the given set of image pairs, optionally with flows and titles.
    Args:
        img_pairs: image pairs in [batch_size, 2, H, W, 3] or list([2, H, W, 3]) format.
        flow_pyrs: optional, predicted optical flow pyramids [batch_size, H, W, 2] or list([H, W, 2]) format.
        num_lvls: number of levels to show per pyramid (flow_pyrs must be set)
        flow_preds: optional, predicted flows in [batch_size, H, W, 2] or list([H, W, 2]) format.
        flow_gts: optional, groundtruth flows in [batch_size, H, W, 2] or list([H, W, 2]) format.
        titles: optional, list of image and flow IDs to display with each image.
        info: optional, stats to display above predicted flow
        flow_mag_max: Max flow to map to 255
    Returns:
        plt: plot
    """
    # Setup drawing canvas
    fig_height, fig_width = 5, 5
    row_count = len(img_pairs)###row_count=1
    col_count = 2
    if flow_preds is not None:
        col_count += 1 #3
    if flow_gts is not None:
        col_count += 1# 4
    if flow_pyrs is not None:
        row_count += len(img_pairs) #2
        jump = num_lvls - col_count #0
        col_count = max(num_lvls, col_count) #4
    plt.figure(figsize=(fig_width * col_count, fig_height * row
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值