forked from open-mmlab/mmdetection3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetricSummaryPlotter.py
130 lines (110 loc) · 3.93 KB
/
metricSummaryPlotter.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
import numpy as np
import matplotlib.pyplot as plt
# set width of bar
import json
classList = ['car','truck','bus','trailer','construction_vehicle','pedestrian','motorcycle','bicycle','traffic_cone','barrier']
modelListGT = ['no_gt_sampler',
'baseline_no_fade',
'baseline_with_fade']
modelListAll = ['no_gt_sampler',
'baseline_no_fade',
'baseline_with_fade',
'v3_fps_ds',
'v3_fps_ds_fade',
'v3_random_ds',
'v3_random_ds_fade',
'v4_random_ds',
'v4_random_ds_fade',
'v4_longrange_bias',
'v4_longrange_bias_with_fade',
'v5_no_fade',
'v5_with_fade',
'v6_no_fade',
'v6_with_fade']
modelListFade = [ 'no_gt_sampler',
'baseline_with_fade',
'v3_fps_ds_fade',
'v3_random_ds_fade',
'v4_random_ds_fade',
'v4_longrange_bias_with_fade',
'v5_with_fade',
'v6_with_fade']
modelListNoFade = [ 'no_gt_sampler',
'baseline_no_fade',
'v3_fps_ds',
'v3_random_ds',
'v4_random_ds',
'v4_longrange_bias',
'v5_no_fade',
'v6_no_fade']
modelList = modelListGT
clas = 'car'
# clas = 'truck'
# clas = 'bus'
# clas = 'trailer'
# clas = 'construction_vehicle'
# clas = 'pedestrian'
# clas = 'motorcycle'
# clas = 'bicycle'
# clas = 'traffic_cone'
# clas = 'barrier'
# dist = '0.5'
# metric = 'label_aps'
# metric = 'mean_dist_aps'
metric = 'nd_score'
# metric = 'mean_ap'
barWidth = 0.1
lim_y = False
lim_weights = [0.6, 1.1]
pp = 'pp/'
modelversion = 'v5_with_fade'
datapath = 'results/filtered/' + pp + modelversion + '/' + modelversion + '_metrics_summary_filtered.json'
datapaths = ['results/filtered/' + pp + vers + '/' + vers + '_metrics_summary_filtered.json' for vers in modelList]
data = {}
for i in range(len(modelList)):
f = open(datapaths[i])
data[modelList[i]] = json.load(f)
print(data['no_gt_sampler'].keys())
print(data['no_gt_sampler']['mean_dist_aps'].keys())
print(data['no_gt_sampler']['mean_dist_aps']['car'])
# for model in modelList:
# d = [data[model]['label_aps'][k][]]
# print(data['no_gt_sampler'][rang][clas].keys())
# print(data['no_gt_sampler'][rang][clas][dist].keys())
fig, ax = plt.subplots(figsize =(16, 8))
# maxVal = 0
# vals = np.arange(len(modelList)).tolist()
# for i in range(len(modelList)):
# valueList = [data[modelList[i]][rang][clas][d][val] for d in data[modelList[i]][rang][clas].keys()]
# tmp = max(valueList)
# if tmp > maxVal:
# maxVal = tmp
# vals[i] = valueList
# Set position of bar on X axis
# br = np.arange(len(modelList)).tolist()
# for i in range(len(modelList)):
# br[i] = np.arange(len(vals[i])) + i*barWidth
# Make the plot
if metric == 'label_aps':
vals = [data[d][metric][clas][dist] for d in modelList]
elif metric == 'mean_dist_aps':
vals = [data[d][metric][clas] for d in modelList]
if modelList == modelListGT:
print('%s & %.3f \t & %.3f \t & %.3f' % (clas,vals[0], vals[1], vals[2]))
else:
vals = [data[d][metric] for d in modelList]
if modelList == modelListGT:
print('%s & %.3f \t & %.3f \t & %.3f' % (clas,vals[0], vals[1], vals[2]))
plt.bar(np.arange(len(vals)), vals, width = barWidth, edgecolor ='grey', label =modelList[i])
maxVal = max(vals)
# Adding Xticks
plt.xlabel('Model', fontweight ='bold', fontsize = 15)
plt.axhline(y=maxVal,linewidth=1, color='k')
if lim_y:
ax.set_ylim([lim_weights[0]*maxVal,lim_weights[1]*maxVal])
plt.ylabel(metric, fontweight ='bold', fontsize = 15)
plt.xticks([r for r in range(len(vals))],
modelList)
ax.set_xticklabels(modelList,rotation='vertical')
plt.legend()
# plt.show()