-
Notifications
You must be signed in to change notification settings - Fork 0
/
tboard_helpers.py
104 lines (94 loc) · 3.08 KB
/
tboard_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import torch
from render_utils import render
from run_nerf_helpers import induce_flow, normalize_depth, percentile
from utils.flow_utils import flow_to_image
def write_static_imgs(writer, i, ret, target, mask, key=""):
writer.add_image(f"{key}rgb_gt", target, global_step=i, dataformats="HWC")
writer.add_image(f"{key}mask", mask, global_step=i, dataformats="HW")
writer.add_image(
f"{key}rgb",
torch.clamp(ret["rgb_map_full"], 0.0, 1.0),
global_step=i,
dataformats="HWC",
)
writer.add_image(
f"{key}depth",
normalize_depth(ret["depth_map_full"]),
global_step=i,
dataformats="HW",
)
if "dynamicness_map_full" in ret:
writer.add_image(
f"{key}dynamicness",
ret["dynamicness_map_full"],
global_step=i,
dataformats="HW",
)
writer.add_image(f"{key}acc", ret["acc_map_full"], global_step=i, dataformats="HW")
def write_dynamic_imgs(
writer, i, ret, target_rgb, grid, invdepth, masks, pose_f, pose_b, hwf
):
H, W, focal = tuple(hwf)
# flow_f_img = flow_to_image(grid[..., 2:4].cpu().numpy())
# flow_b_img = flow_to_image(grid[..., 5:7].cpu().numpy())
# induced_flow_f = induce_flow(
# H,
# W,
# focal,
# pose_f,
# ret["weights_d"],
# ret["raw_pts_f"],
# grid[..., :2],
# )
# induced_flow_f_img = flow_to_image(induced_flow_f.cpu().numpy())
# induced_flow_b = induce_flow(
# H,
# W,
# focal,
# pose_b,
# ret["weights_d"],
# ret["raw_pts_b"],
# grid[..., :2],
# )
# induced_flow_b_img = flow_to_image(induced_flow_b.cpu().numpy())
# writer.add_image(
# "induced_flow_f",
# induced_flow_f_img,
# global_step=i,
# dataformats="HWC",
# )
# writer.add_image(
# "induced_flow_b",
# induced_flow_b_img,
# global_step=i,
# dataformats="HWC",
# )
# writer.add_image("flow_f_gt", flow_f_img, global_step=i, dataformats="HWC")
# writer.add_image("flow_b_gt", flow_b_img, global_step=i, dataformats="HWC")
for idx, inv in enumerate(invdepth):
writer.add_image(
f"disp/{idx}",
torch.clamp(inv / percentile(inv, 97), 0.0, 1.0),
global_step=i,
dataformats="HW",
)
writer.add_image(f"mask/{idx}", masks[idx], global_step=i, dataformats="HW")
writer.add_image(
f"rgb_gt/{idx}", target_rgb[idx], global_step=i, dataformats="HWC"
)
for idx, inv in enumerate(ret["rgb_map_obj"]):
writer.add_image(
f"rgb_obj/{idx}",
torch.clamp(ret["rgb_map_obj"][idx], 0.0, 1.0),
global_step=i,
dataformats="HWC",
)
writer.add_image(
f"acc_obj/{idx}", ret["acc_map_obj"][idx], global_step=i, dataformats="HW"
)
writer.add_image(
f"dynamicness/{idx}",
ret["dynamicness_map_obj"][idx],
global_step=i,
dataformats="HW",
)