-
Notifications
You must be signed in to change notification settings - Fork 35
/
display.py
50 lines (42 loc) · 1.79 KB
/
display.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
from os import listdir
import argparse
import numpy as np
import visdom
import pickle
import time
def main(args):
vis = visdom.Visdom(port=8097)
losses = pickle.load( open( "results/saved_loss.p", "rb" ) )
x=np.squeeze(np.asarray(losses["X"]))
l=np.squeeze(np.asarray(losses["Y"]))
ltest=np.squeeze(np.asarray(losses["Y_test"]))
vis.line(np.vstack((l,ltest)).T, x, env='loss_acc', opts=dict(title="Loss"))
accuracy = pickle.load( open( "results/saved_accuracy.p", "rb" ) )
x=np.squeeze(np.asarray(accuracy["X"]))
P = accuracy["P"]
M = accuracy["M"]
I = accuracy["I"]
Ptest = accuracy["P_test"]
Mtest = accuracy["M_test"]
Itest = accuracy["I_test"]
vis.line(np.vstack((P.T, Ptest.T)).T, x, env='loss_acc', opts=dict(title="Pixel Accuracy"))
vis.line(np.vstack((M.T, Mtest.T)).T, x, env='mean_acc', opts=dict(title="Mean Accuracy"))
vis.line(np.vstack((I.T, Itest.T)).T, x, env='IoU', opts=dict(title="Mean IoU"))
if args.images:
onlyfiles = [f for f in listdir('./results/saved_val_images')]
onlyfiles.sort()
for f in onlyfiles:
if f.endswith('.p'):
image = pickle.load( open( "results/saved_val_images/"+f, "rb" ) )
if len(image.shape) == 4:
vis.image(image[0], env='images', opts=dict(title=f))
else:
if image.shape[0] != 3:
image = image.transpose((2,0,1))
vis.image(image, env='images', opts=dict(title=f))
time.sleep(0.25)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Params')
parser.add_argument('--images', help='Also displays images from validation set', action='store_true')
args = parser.parse_args()
main(args)