-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_results.py
executable file
·73 lines (51 loc) · 2.49 KB
/
plot_results.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
import numpy as np
import matplotlib.pyplot as plt
import os
for i in range(1, 5+1): #base shape
max = 5
crowdeds = [[i], [i, i, i], [i, i, i, i, i]]
uncrowdeds = []
for j in range(1, max + 1):
if j != i:
uncrowdeds += [[i, j, i, j, i]]
# load results
LOGDIR = 'crowd-master1_logdir/version_test_hidden_512'
vernier = np.squeeze(np.load(LOGDIR+'/vernier_and_shapes_percent_correct[].npy'))
crow = [[],[],[]]
for t in range (3):
crow[t] = np.squeeze(np.load(LOGDIR+'/vernier_and_shapes_percent_correct' + str(crowdeds[t]) + '.npy'))
uncrow = [[], [], [], []]
for t in range(4):
uncrow[t] = np.squeeze(np.load(LOGDIR + '/vernier_and_shapes_percent_correct' + str(uncrowdeds[t]) + '.npy'))
# cosmetics
layers = ['conv1', 'conv2', 'conv3', 'conv4', 'conv5', 'fc6', 'fc7', 'fc8', 'prob']
####### PLOT RESULTS #######
N = len(layers)
ind = np.arange(N) # the x locations for the groups
width = 0.11 # the width of the bars
#define plots
fig, ax = plt.subplots()
#increase image size
fig.set_size_inches(18.5, 10.5)
fig.savefig('test2png.png', dpi=100)
#Define bars of histogram
rects1 = ax.bar(ind, vernier, width, color=(146./255, 181./255, 88./255))
rects21 = ax.bar(ind + width, crow[0], width, color=(220./255, 76./255, 70./255))
rects22 = ax.bar(ind + 2*width, crow[1], width, color=(235./255, 76./255, 70./255))
rects23 = ax.bar(ind + 3*width, crow[2], width, color=(250./255, 76./255, 70./255))
rects31 = ax.bar(ind + 4*width, uncrow[0], width, color=(79./255, 132./255, 196./255))
rects32 = ax.bar(ind + 5*width, uncrow[1], width, color=(79./255, 142./255, 206./255))
rects33 = ax.bar(ind + 6*width, uncrow[2], width, color=(79./255, 152./255, 216./255))
rects34 = ax.bar(ind + 7*width, uncrow[3], width, color=(79./255, 162./255, 226./255))
# add some text for labels, title and axes ticks, and save figure
ax.set_ylabel('Percent correct')
ax.set_title('Vernier decoding from alexnet layers')
ax.set_xticks(ind + width / 2)
ax.set_xticklabels(layers)
ax.plot([-0.3,N], [50, 50], 'r--') # chance level cashed line
ax.legend((rects1[0], rects21[0], rects31[0]), ('vernier', 'crowding 1-3-5', 'uncrowding, 5 shapes'))
os.makedirs(LOGDIR+'/_plots', exist_ok=True)
plt.savefig(LOGDIR+'/_plots/00Shape'+str(i)+'_plot.png')
plt.ylim(30,100)
plt.savefig(LOGDIR+'/_plots/30Shape'+str(i)+'_plot.png')
#rect4 = ax.bar(ind)