1
1
import argparse
2
2
import time
3
3
import numpy as np
4
+
5
+ # import matplotlib
6
+ # matplotlib.use('agg')
4
7
import matplotlib .pyplot as plt
5
8
6
9
from dr_spaam .detector import Detector
@@ -13,25 +16,32 @@ def inference_time():
13
16
14
17
# inference time
15
18
use_gpu = True
16
- for use_drow in (True , False ):
17
- ckpt = './ckpts/drow_e40.pth' if use_drow else './ckpts/dr_spaam_e40.pth'
18
- detector = Detector (ckpt , original_drow = use_drow , gpu = use_gpu , stride = 1 )
19
+ model_names = ("DR-SPAAM" , "DROW" , "DROW-T5" )
20
+ ckpts = (
21
+ "./ckpts/dr_spaam_e40.pth" ,
22
+ "./ckpts/drow_e40.pth" ,
23
+ "./ckpts/drow5_e40.pth"
24
+ )
25
+ for model_name , ckpt in zip (model_names , ckpts ):
26
+ detector = Detector (model_name = model_name , ckpt_file = ckpt , gpu = use_gpu , stride = 1 )
19
27
detector .set_laser_spec (angle_inc = np .radians (0.5 ), num_pts = 450 )
20
28
21
29
t_list = []
22
30
for i in range (60 ):
31
+ s = scans [i :i + 5 ] if model_name == "DROW-T5" else scans [i ]
23
32
t0 = time .time ()
24
- dets_xy , dets_cls , instance_mask = detector (scans [ i ] )
33
+ dets_xy , dets_cls , instance_mask = detector (s )
25
34
t_list .append (1e3 * (time .time () - t0 ))
26
35
27
36
t = np .array (t_list [10 :]).mean ()
28
37
print ("inference time (model: %s, gpu: %s): %f ms (%.1f FPS)" % (
29
- "DROW" if use_drow else "DR-SPAAM" , use_gpu , t , 1e3 / t ))
38
+ model_name , use_gpu , t , 1e3 / t ))
30
39
31
40
32
41
def play_sequence ():
33
42
# scans
34
43
seq_name = './data/DROWv2-data/test/run_t_2015-11-26-11-22-03.bag.csv'
44
+ # seq_name = './data/DROWv2-data/val/run_2015-11-26-15-52-55-k.bag.csv'
35
45
scans_data = np .genfromtxt (seq_name , delimiter = ',' )
36
46
scans_t = scans_data [:, 1 ]
37
47
scans = scans_data [:, 2 :]
@@ -45,7 +55,7 @@ def play_sequence():
45
55
46
56
# detector
47
57
ckpt = './ckpts/dr_spaam_e40.pth'
48
- detector = Detector (ckpt , original_drow = False , gpu = True , stride = 1 )
58
+ detector = Detector (model_name = "DR-SPAAM" , ckpt_file = ckpt , gpu = True , stride = 1 )
49
59
detector .set_laser_spec (angle_inc = np .radians (0.5 ), num_pts = 450 )
50
60
51
61
# scanner location
@@ -54,7 +64,7 @@ def play_sequence():
54
64
xy_scanner = np .stack (xy_scanner , axis = 1 )
55
65
56
66
# plot
57
- fig = plt .figure (figsize = (9 , 6 ))
67
+ fig = plt .figure (figsize = (10 , 10 ))
58
68
ax = fig .add_subplot (111 )
59
69
60
70
_break = False
@@ -67,11 +77,12 @@ def p(event):
67
77
# video sequence
68
78
odo_idx = 0
69
79
for i in range (len (scans )):
80
+ # for i in range(0, len(scans), 20):
70
81
plt .cla ()
71
82
72
83
ax .set_aspect ('equal' )
73
84
ax .set_xlim (- 15 , 15 )
74
- ax .set_ylim (- 5 , 15 )
85
+ ax .set_ylim (- 15 , 15 )
75
86
76
87
# ax.set_title('Frame: %s' % i)
77
88
ax .set_title ('Press any key to exit.' )
@@ -104,10 +115,11 @@ def p(event):
104
115
for j in range (len (dets_xy )):
105
116
if dets_cls [j ] < cls_thresh :
106
117
continue
107
- c = plt .Circle (dets_xy_rot [j ], radius = 0.5 , color = 'r' , fill = False )
118
+ # c = plt.Circle(dets_xy_rot[j], radius=0.5, color='r', fill=False)
119
+ c = plt .Circle (dets_xy_rot [j ], radius = 0.5 , color = 'r' , fill = False , linewidth = 2 )
108
120
ax .add_artist (c )
109
121
110
- # plt.savefig('/home/jia/tmp_imgs/dets /frame_%04d.png' % i)
122
+ # plt.savefig('/home/dan/tmp/det_img /frame_%04d.png' % i)
111
123
112
124
plt .pause (0.001 )
113
125
@@ -118,7 +130,7 @@ def p(event):
118
130
def play_sequence_with_tracking ():
119
131
# scans
120
132
seq_name = './data/DROWv2-data/train/lunch_2015-11-26-12-04-23.bag.csv'
121
- seq0 , seq1 = 107000 , 109357
133
+ seq0 , seq1 = 109170 , 109360
122
134
scans , scans_t = [], []
123
135
with open (seq_name ) as f :
124
136
for line in f :
@@ -142,7 +154,7 @@ def play_sequence_with_tracking():
142
154
143
155
# detector
144
156
ckpt = './ckpts/dr_spaam_e40.pth'
145
- detector = Detector (ckpt , original_drow = False , gpu = True , stride = 1 )
157
+ detector = Detector (model_name = "DR-SPAAM" , ckpt_file = ckpt , gpu = True , stride = 1 , tracking = True )
146
158
detector .set_laser_spec (angle_inc = np .radians (0.5 ), num_pts = 450 )
147
159
148
160
# scanner location
@@ -151,7 +163,7 @@ def play_sequence_with_tracking():
151
163
xy_scanner = np .stack (xy_scanner , axis = 1 )
152
164
153
165
# plot
154
- fig = plt .figure (figsize = (9 , 6 ))
166
+ fig = plt .figure (figsize = (6 , 8 ))
155
167
ax = fig .add_subplot (111 )
156
168
157
169
_break = False
@@ -167,7 +179,7 @@ def p(event):
167
179
plt .cla ()
168
180
169
181
ax .set_aspect ('equal' )
170
- ax .set_xlim (- 15 , 15 )
182
+ ax .set_xlim (- 10 , 5 )
171
183
ax .set_ylim (- 5 , 15 )
172
184
173
185
# ax.set_title('Frame: %s' % i)
@@ -193,15 +205,15 @@ def p(event):
193
205
ax .scatter (scan_x , scan_y , s = 1 , c = 'blue' )
194
206
195
207
# inference
196
- dets_xy , dets_cls , instance_mask = detector (scan , tracking = True )
208
+ dets_xy , dets_cls , instance_mask = detector (scan )
197
209
198
210
# plot detection
199
211
dets_xy_rot = np .matmul (dets_xy , odo_rot .T )
200
212
cls_thresh = 0.3
201
213
for j in range (len (dets_xy )):
202
214
if dets_cls [j ] < cls_thresh :
203
215
continue
204
- c = plt .Circle (dets_xy_rot [j ], radius = 0.5 , color = 'r' , fill = False )
216
+ c = plt .Circle (dets_xy_rot [j ], radius = 0.5 , color = 'r' , fill = False , linewidth = 2 )
205
217
ax .add_artist (c )
206
218
207
219
# plot track
@@ -210,9 +222,9 @@ def p(event):
210
222
for t , tc in zip (tracks , tracks_cls ):
211
223
if tc >= cls_thresh and len (t ) > 1 :
212
224
t_rot = np .matmul (t , odo_rot .T )
213
- ax .plot (t_rot [:, 0 ], t_rot [:, 1 ], color = 'g' )
225
+ ax .plot (t_rot [:, 0 ], t_rot [:, 1 ], color = 'g' , linewidth = 2 )
214
226
215
- # plt.savefig('/home/jia/tmp_imgs/tracks /frame_%05d .png' % i)
227
+ # plt.savefig('/home/dan/tmp/track3_img /frame_%04d .png' % i)
216
228
217
229
plt .pause (0.001 )
218
230
0 commit comments