@@ -63,20 +63,21 @@ def __init__(self, config):
63
63
self .diff_processor .start ()
64
64
65
65
# start the thread for edge server
66
- self .edge_server = threading .Thread (target = self .start_edge_server , daemon = True )
67
- self .edge_server .start ()
66
+ # self.edge_server = threading.Thread(target=self.start_edge_server, daemon=True)
67
+ # self.edge_server.start()
68
68
69
69
# start the thread for local process
70
70
self .local_processor = threading .Thread (target = self .local_worker ,daemon = True )
71
71
self .local_processor .start ()
72
72
73
73
# start the thread for retrain process
74
74
self .collect_flag = self .config .retrain .flag
75
+ self .collect_time = None
76
+ self .collect_time_flag = True
75
77
self .retrain_flag = False
76
78
self .cache_count = 0
77
79
78
80
self .use_history = True
79
- self .test_only = False
80
81
self .retrain_no = 0
81
82
82
83
self .retrain_processor = threading .Thread (target = self .retrain_worker ,daemon = True )
@@ -180,7 +181,12 @@ def local_worker(self):
180
181
181
182
# collect data for retrain
182
183
if self .collect_flag :
183
- self .collect_data (task , current_frame ,detection_boxes , detection_class , detection_score )
184
+ if self .collect_time_flag :
185
+ self .collect_time = time .time ()
186
+ self .collect_time_flag = False
187
+ duration = time .time () - self .collect_time
188
+ if duration > self .config .retrain .window :
189
+ self .collect_data (task , current_frame ,detection_boxes , detection_class , detection_score )
184
190
185
191
if detection_boxes is not None :
186
192
task .add_result (detection_boxes , detection_class , detection_score )
@@ -308,10 +314,6 @@ def collect_data(self, task, frame ,detection_boxes, detection_class, detection_
308
314
self .pred_res = []
309
315
self .collect_flag = False
310
316
self .cache_count = 0
311
- if self .retrain_no % self .config .retrain .interval == 0 :
312
- self .test_only = True
313
- else :
314
- self .test_only = False
315
317
self .retrain_flag = True
316
318
317
319
@@ -332,17 +334,10 @@ def retrain_worker(self):
332
334
np .savetxt (os .path .join (self .config .retrain .cache_path ,'annotation.txt' ), self .annotations ,
333
335
fmt = ['%d' , '%d' , '%f' , '%f' , '%f' , '%f' , '%f' ], delimiter = ',' )
334
336
335
- if self .test_only :
336
- logger .debug ("test only" )
337
- self .small_object_detection .model_evaluation (
338
- self .config .retrain .cache_path , self .select_index )
339
- else :
340
- self .small_object_detection .model_evaluation (
341
- self .config .retrain .cache_path , self .select_index [int (self .config .retrain .select_num * 0.8 ):])
342
- self .small_object_detection .retrain (
343
- self .config .retrain .cache_path , self .select_index [:int (self .config .retrain .select_num * 0.8 )])
344
- self .small_object_detection .model_evaluation (
345
- self .config .retrain .cache_path , self .select_index [int (self .config .retrain .select_num * 0.8 ):])
337
+ self .small_object_detection .model_evaluation (
338
+ self .config .retrain .cache_path , self .select_index )
339
+ self .small_object_detection .retrain (
340
+ self .config .retrain .cache_path , self .select_index [:int (self .config .retrain .select_num * 0.8 )])
346
341
self .retrain_flag = False
347
342
if self .use_history :
348
343
self .select_index ,self .avg_scores = history_sample (self .select_index ,self .avg_scores )
@@ -354,8 +349,10 @@ def retrain_worker(self):
354
349
self .select_index = []
355
350
self .avg_scores = []
356
351
self .annotations = []
352
+ self .collect_time_flag = True
357
353
self .collect_flag = True
358
- time .sleep (1 )
354
+ time .sleep (0.2 )
355
+
359
356
360
357
361
358
def start_edge_server (self ):
0 commit comments