-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_graphs.py
executable file
·51 lines (39 loc) · 1.63 KB
/
generate_graphs.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
#!/usr/bin/env python3
import json
import matplotlib.pyplot as plt
import numpy as np
"""
https://stackoverflow.com/questions/21444338/transpose-nested-list-in-python
"""
class Results:
def __init__(self):
self.loss = None
self.validation = None
unet_results = Results()
segresnet_results = Results()
result_type = "multi"
with open(f"results/data/{result_type}-channel/unet-training-loss.json") as UL:
unet_results.loss = np.array(json.load(UL)).T.tolist()
with open(f"results/data/{result_type}-channel/unet-validation-mean-dice.json") as UV:
unet_results.validation = np.array(json.load(UV)).T.tolist()
with open(f"results/data/{result_type}-channel/segresnet-training-loss.json") as SL:
segresnet_results.loss = np.array(json.load(SL)).T.tolist()
with open(f"results/data/{result_type}-channel/segresnet-validation-mean-dice.json") as SV:
segresnet_results.validation = np.array(json.load(SV)).T.tolist()
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5)) # format width, height
ax[0].set_title("Training Loss")
ax[0].set_xlabel("Epoch")
ax[0].plot(unet_results.loss[1], unet_results.loss[2], label="Residual U-Net", color="#ff7f0e")
ax[0].plot(segresnet_results.loss[1], segresnet_results.loss[2], label="SegResNet")
ax[1].set_title("Validation Score")
ax[1].set_xlabel("Epoch")
ax[1].plot(
unet_results.validation[1],
unet_results.validation[2],
label="Residual U-Net",
color="#ff7f0e",
)
ax[1].plot(segresnet_results.validation[1], segresnet_results.validation[2], label="SegResNet")
handles, labels = ax[1].get_legend_handles_labels()
fig.legend(handles, labels, loc="center right")
plt.show()