-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting.py
305 lines (288 loc) · 15.3 KB
/
plotting.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import matplotlib.pyplot as plt
import numpy as np
import helper_functions
def plot_generator_losses(gen_tc2od_losses,
gen_od2tc_losses,
total_cycle_losses,
total_cycle_losses_d2d,
gen_od2td_losses,
gen_td2od_losses,
total_gen_tc2od_losses,
total_gen_od2tc_losses,
total_gen_od2td_losses,
total_gen_td2od_losses,
identity_losses_od2td,
identity_losses_td2od):
# same_result_losses,
# total_supercycle_losses,
# identity_losses_od2td,
# identity_losses_td2od,
# half_cycle_losses_td2tg,
# half_cycle_losses_tg2td
plt.figure(figsize=(10, 5))
plt.plot(list(zip(gen_tc2od_losses,
gen_od2tc_losses,
total_cycle_losses,
total_gen_tc2od_losses,
total_gen_od2tc_losses)))
plt.title("Generator Losses for Transparent Color to Opaque Depth and vice versa")
plt.legend(["TC2OD GAN",
"OD2TC GAN loss",
"Cycle loss",
"TC2OD loss (GAN+Cycle)",
"OD2TC loss"])
plt.savefig(f"generator_color_losses_latest.png")
plt.figure(figsize=(10, 5))
plt.plot(list(zip(gen_od2td_losses,
gen_td2od_losses,
total_cycle_losses_d2d,
identity_losses_od2td,
identity_losses_td2od,
total_gen_od2td_losses,
total_gen_td2od_losses)))
# same_result_losses,
# total_supercycle_losses,
# identity_losses_od2td,
# identity_losses_td2od,
# half_cycle_losses_td2tg,
# half_cycle_losses_tg2td
plt.title("Generator Losses for Opaque Depth to Transparent Depth and vice versa")
plt.legend(["OD2TD GAN",
"TD2OD GAN",
"Cycle",
"OD2TD Identity",
"TD2OD Identity",
"OD2TD (GAN+Cycle+Identity)",
"TD2OD"])
# "Same result loss",
# "Supercycle loss",
# "Identity loss OD2TD",
# "Identity loss TD2OD",
# "Half cycle loss TD2TG",
# "Half cycle loss TG2TD"])
plt.savefig(f"generator_depth_losses_latest.png")
def plot_discriminator_losses(disc_x_losses,
disc_y_losses,
disc_td2od_losses,
disc_td_losses,
disc_od_losses):
plt.figure(figsize=(10, 5))
plt.plot(list(zip(disc_x_losses,
disc_y_losses,
disc_td2od_losses,
disc_td_losses,
disc_od_losses)))
plt.title("Discriminator Losses")
plt.legend(["Discriminator TC loss",
"Discriminator TC2OD loss",
"Discriminator TD2OD loss",
"Discriminator TD loss",
"Discriminator OD loss (TC2OD + TD2OD)"])
plt.savefig(f"discriminator_losses_latest.png")
def plot_discriminator_performance(dataset,
discriminator_x,
discriminator_y,
discriminator_td,
generator_g,
generator_f,
generator_td2od,
generator_od2td,
discriminator_actual_x_mean,
discriminator_actual_y_mean,
discriminator_actual_td_mean,
discriminator_fake_x_mean,
discriminator_fake_y_mean,
discriminator_fake_td2od_mean,
discriminator_fake_od2td_mean):
d_actual_x_running_mean = 0
d_actual_y_running_mean = 0
d_actual_td_running_mean = 0
d_fake_x_running_mean = 0
d_fake_y_running_mean = 0
d_fake_td2od_running_mean = 0
d_fake_od2td_running_mean = 0
n = 0
for transparent, opaque in dataset.take(10):
transparent_color = transparent[2]
opaque_depth = opaque[0]
transparent_depth = transparent[0]
fake_x = generator_f(opaque_depth)
fake_y = generator_g(transparent_color)
fake_td2od = generator_td2od(transparent_depth)
fake_od2td = generator_od2td(opaque_depth)
d_actual_x_running_mean += np.mean(discriminator_x(transparent_color))
d_actual_y_running_mean += np.mean(discriminator_y(opaque_depth))
d_actual_td_running_mean += np.mean(discriminator_td(transparent_depth))
d_fake_x_running_mean += np.mean(discriminator_x(fake_x))
d_fake_y_running_mean += np.mean(discriminator_y(fake_y))
d_fake_td2od_running_mean += np.mean(discriminator_y(fake_td2od))
d_fake_od2td_running_mean += np.mean(discriminator_td(fake_od2td))
n += 1
discriminator_actual_x_mean.append(d_actual_x_running_mean / n)
discriminator_actual_y_mean.append(d_actual_y_running_mean / n)
discriminator_actual_td_mean.append(d_actual_td_running_mean / n)
discriminator_fake_x_mean.append(d_fake_x_running_mean / n)
discriminator_fake_y_mean.append(d_fake_y_running_mean / n)
discriminator_fake_td2od_mean.append(d_fake_td2od_running_mean / n)
discriminator_fake_od2td_mean.append(d_fake_od2td_running_mean / n)
plt.figure(figsize=(10, 5))
plt.plot(list(zip(discriminator_actual_x_mean,
discriminator_actual_y_mean,
discriminator_fake_x_mean,
discriminator_fake_y_mean)))
plt.title("Discriminator Performance on Transparent Color and Opaque Depth")
plt.legend(["Discriminator TC on Actual TC",
"Discriminator OD on Actual OD",
"Discriminator TC on Generated TC",
"Discriminator OD on Generated OD (from TC)"])
plt.savefig(f"discriminator_grayscale_performance_latest.png")
plt.figure(figsize=(10, 5))
plt.plot(list(zip(discriminator_actual_y_mean,
discriminator_actual_td_mean,
discriminator_fake_td2od_mean,
discriminator_fake_od2td_mean)))
plt.title("Discriminator Performance on Opaque Depth and Transparent Depth")
plt.legend(["Discriminator OD on actual OD",
"Discriminator TD on actual TD",
"Discriminator OD on Generated OD (from TD)",
"Discriminator TD on Generated TD"])
plt.savefig(f"discriminator_depth_performance_latest.png")
def plot_depth_to_depth_results(cleargrasp_transparent_rgb_test_cs_rz,
cleargrasp_transparent_depth_test_cs_rz,
cleargrasp_transparent_depth_test_max,
cleargrasp_opaque_depth_test_cs_rz,
cleargrasp_opaque_depth_test_max,
cleargrasp_masks_test,
generate_test,
generate_test_td2od,
epoch,
rmse_baselines_test_tg2od,
mae_baselines_test_tg2od,
rmse_differences_test_tg2od,
mae_differences_test_tg2od,
rmse_baselines_test_td2od,
mae_baselines_test_td2od,
rmse_differences_test_td2od, mae_differences_test_td2od):
rmse_baseline_test_tg2od, \
mae_baseline_test_tg2od, \
rmse_difference_test_tg2od, \
mae_difference_test_tg2od = \
helper_functions.evaluate_dataset_rgb_to_depth(cleargrasp_transparent_rgb_test_cs_rz,
cleargrasp_transparent_depth_test_cs_rz,
cleargrasp_transparent_depth_test_max,
"ClearGrasp transparent",
cleargrasp_opaque_depth_test_cs_rz,
cleargrasp_opaque_depth_test_max,
"ClearGrasp opaque",
cleargrasp_masks_test,
generate_test(),
f"test_set_tg2od_ep{epoch}",
True,
len(cleargrasp_transparent_depth_test_cs_rz))
rmse_baseline_test_td2od, \
mae_baseline_test_td2od, \
rmse_difference_test_td2od, \
mae_difference_test_td2od = \
helper_functions.evaluate_dataset(cleargrasp_transparent_depth_test_cs_rz,
cleargrasp_transparent_depth_test_max,
"ClearGrasp transparent",
cleargrasp_opaque_depth_test_cs_rz,
cleargrasp_opaque_depth_test_max,
"ClearGrasp opaque",
cleargrasp_masks_test,
cleargrasp_transparent_rgb_test_cs_rz,
generate_test_td2od(),
f"test_set_td2od_ep{epoch}",
True,
len(cleargrasp_transparent_depth_test_cs_rz))
rmse_baselines_test_tg2od.append(rmse_baseline_test_tg2od)
mae_baselines_test_tg2od.append(mae_baseline_test_tg2od)
rmse_differences_test_tg2od.append(rmse_difference_test_tg2od)
mae_differences_test_tg2od.append(mae_difference_test_tg2od)
rmse_baselines_test_td2od.append(rmse_baseline_test_td2od)
mae_baselines_test_td2od.append(mae_baseline_test_td2od)
rmse_differences_test_td2od.append(rmse_difference_test_td2od)
mae_differences_test_td2od.append(mae_difference_test_td2od)
plt.figure(figsize=(10, 5))
plt.plot(list(zip(rmse_baselines_test_tg2od,
mae_baselines_test_tg2od,
rmse_differences_test_tg2od,
mae_differences_test_tg2od)))
plt.title("Evaluation of TC2OD on ClearGrasp")
plt.legend(["CG Baseline RMSE",
"CG Baseline MAE",
"CG TC2OD RMSE",
"CG TC2OD MAE"])
plt.savefig(f"tc2od_latest.png")
plt.figure(figsize=(10, 5))
plt.plot(list(zip(rmse_baselines_test_td2od,
mae_baselines_test_td2od,
rmse_differences_test_td2od,
mae_differences_test_td2od)))
plt.title("Evaluation of TD2OD on ClearGrasp")
plt.legend(["CG Baseline RMSE",
"CG Baseline MAE",
"CG TD2OD RMSE",
"CG TD2OD MAE"])
plt.savefig(f"td2od_latest.png")
def plot_grayscale_to_depth_results(transparent_rgb_matching_cs_rz, transparent_depth_matching, transparent_depth_matching_max, opaque_depth_matching, opaque_depth_matching_max, mask_matching, transparent_rgb_matching, generate_ours_tg2od, generate_ours_td2od, rmse_baselines_ours_tg2od, mae_baselines_ours_tg2od, rmse_differences_ours_tg2od, mae_differences_ours_tg2od, rmse_baselines_ours_td2od, mae_baselines_ours_td2od, rmse_differences_ours_td2od, mae_differences_ours_td2od):
rmse_baseline_ours_tg2od, \
mae_baseline_ours_tg2od, \
rmse_difference_ours_tg2od, \
mae_difference_ours_tg2od = helper_functions.evaluate_dataset_rgb_to_depth(transparent_rgb_matching_cs_rz,
np.squeeze(np.array(list(iter(transparent_depth_matching)))),
transparent_depth_matching_max,
"Ours transparent",
np.squeeze(np.array(list(iter(opaque_depth_matching)))),
opaque_depth_matching_max,
"Ours opaque",
np.squeeze(np.array(mask_matching)),
generate_ours_tg2od(),
"ours_tg2od",
True,
len(list(iter(transparent_depth_matching))))
rmse_baseline_ours_td2od, \
mae_baseline_ours_td2od, \
rmse_difference_ours_td2od, \
mae_difference_ours_td2od = helper_functions.evaluate_dataset(np.squeeze(np.array(list(iter(transparent_depth_matching)))),
transparent_depth_matching_max,
"Ours transparent",
np.squeeze(np.array(list(iter(opaque_depth_matching)))),
opaque_depth_matching_max,
"Ours opaque",
np.squeeze(np.array(mask_matching)),
np.array(transparent_rgb_matching),
generate_ours_td2od(),
"ours_td2od",
True,
len(list(iter(transparent_depth_matching))))
rmse_baselines_ours_tg2od.append(rmse_baseline_ours_tg2od)
mae_baselines_ours_tg2od.append(mae_baseline_ours_tg2od)
rmse_differences_ours_tg2od.append(rmse_difference_ours_tg2od)
mae_differences_ours_tg2od.append(mae_difference_ours_tg2od)
rmse_baselines_ours_td2od.append(rmse_baseline_ours_td2od)
mae_baselines_ours_td2od.append(mae_baseline_ours_td2od)
rmse_differences_ours_td2od.append(rmse_difference_ours_td2od)
mae_differences_ours_td2od.append(mae_difference_ours_td2od)
plt.figure(figsize=(10, 5))
plt.plot(list(zip(rmse_baselines_ours_tg2od,
mae_baselines_ours_tg2od,
rmse_differences_ours_tg2od,
mae_differences_ours_tg2od)))
plt.title("Evaluation of TC2OD on Ours")
plt.legend(["Ours Baseline RMSE",
"Ours Baseline MAE",
"Ours TC2OD RMSE",
"Ours TC2OD MAE"])
plt.savefig(f"tc2od_latest_ours.png")
plt.figure(figsize=(10, 5))
plt.plot(list(zip(rmse_baselines_ours_td2od,
mae_baselines_ours_td2od,
rmse_differences_ours_td2od,
mae_differences_ours_td2od)))
plt.title("Evaluation of TD2OD on Ours")
plt.legend(["Ours Baseline RMSE",
"Ours Baseline MAE",
"Ours TD2OD RMSE",
"Ours TD2OD MAE"])
plt.savefig(f"td2od_latest_ours.png")