-
Notifications
You must be signed in to change notification settings - Fork 1
/
visualize.py
27 lines (25 loc) · 1.08 KB
/
visualize.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
import matplotlib.pyplot as plt
import glob
import os
import numpy as np
# level80_case0035_image
base_path = os.path.join("output_original_single_channel", "predictions-ood")
storage_path = os.path.join("output_original_single_channel", "predictions-ood-processed")
if not os.path.exists(storage_path):
os.mkdir(storage_path)
for level in range(48, 90):
for sigma in range(1, 11):
images = []
for filename in glob.glob(os.path.join(base_path, f"level{level}_case0035_{sigma}_*_prediction.npy")):
# im = plt.imread(filename)
im = np.load(filename)
im[im != 0] = 1
images.append(im)
preds = np.stack(images)
preds.shape
variance = np.var(preds, axis=0)
# variance = (variance - np.min(variance)) / (np.max(variance) - np.min(variance))
print(f"{level} {sigma}")
plt.imshow(variance, cmap="magma")
plt.imsave(os.path.join(storage_path, os.path.splitext(os.path.basename(filename))[0].replace("prediction", "uncertainty") + ".jpg"), variance, cmap="magma")
plt.show()