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