forked from open-mmlab/mmdetection3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetricPlotter.py
145 lines (123 loc) · 4.58 KB
/
metricPlotter.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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']
mod2name = {'no_gt_sampler': 'No GTDS',
'baseline_no_fade': 'Baseline GTDS',
'baseline_with_fade': 'Baseline GTDS + fade',
'v3_random_ds': 'RFS Random',
'v3_random_ds_fade': 'RFS Random + fade',
'v3_fps_ds': 'RFS FPS',
'v3_fps_ds_fade': 'RFS FPS + fade',
'v4_random_ds': 'RRSv1',
'v4_random_ds_fade': 'RRSv1 + fade',
'v4_longrange_bias': 'RRSv2',
'v4_longrange_bias_with_fade': 'RRSv2 + fade',
'v5_no_fade': 'HRFiSv1',
'v5_with_fade': 'HRFiSv1 + fade',
'v6_no_fade': 'HRFiSv2',
'v6_with_fade': 'HRFiSv2 + fade',
'baseline_no_fade_2x': 'Baseline GTDS 2x',
'baseline_with_fade_2x': 'Baseline GTDS 2x + fade'}
modelListGT = ['no_gt_sampler',
'baseline_no_fade',
'baseline_with_fade']
modelListAll = ['no_gt_sampler',
'baseline_no_fade',
'baseline_no_fade_2x',
'baseline_with_fade',
'baseline_with_fade_2x',
'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']
modelListTune = ['no_gt_sampler',
'baseline_no_fade',
'baseline_no_fade_2x',
'baseline_with_fade',
'baseline_with_fade_2x']
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 = modelListTune
rang = 'all'
# 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'
val = 'fp'
barWidth = 0.05
lim_y = False
lim_weights = [0.8, 1.1]
pp = ''
# pp = 'pp/'
modelversion = 'v5_with_fade'
datapath = 'results/filtered/' + pp + modelversion + '/' + modelversion + '_statistics.json'
datapaths = ['results/filtered/' + pp + vers + '/' + vers + '_statistics.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'][rang].keys())
print(data['no_gt_sampler'][rang][clas].keys())
print(data['no_gt_sampler'][rang][clas][dist].keys())
for model in modelList:
d = [data[model][rang][k][dist][val] for k in classList]
print('%s & %i & %i & %i & %i & %i & %i & %i & %i & %i & %i \\\\' % (mod2name[model] ,d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9]))
fig, ax = plt.subplots(figsize =(12, 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 = min(valueList)
print(modelList[i], ': ',tmp)
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
for i in range(len(modelList)):
plt.bar(br[i], vals[i], width = barWidth, edgecolor ='grey', label =modelList[i])
# Adding Xticks
plt.xlabel('Distance Threshold', 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(val, fontweight ='bold', fontsize = 15)
plt.xticks([r + barWidth for r in range(len(vals[1]))],
data[modelList[0]]['long']['car'].keys())
plt.legend()
plt.show()