@@ -328,28 +328,13 @@ def update(self, det_results, ori_img):
328328 lost_stracks = [] # The tracks which are not obtained in the current frame but are not removed.(Lost for some time lesser than the threshold for removing)
329329 removed_stracks = []
330330
331- # convert the scale to origin size
332- # NOTE: yolo v7 origin out format: [xc, yc, w, h, conf, cls0_conf, cls1_conf, ..., clsn_conf]
333- # TODO: check here, if nesscessary use two ratio
334- img_h , img_w = ori_img .shape [0 ], ori_img .shape [1 ]
335- ratio = [img_h / self .model_img_size [0 ], img_w / self .model_img_size [1 ]] # usually > 1
336- det_results [:, 0 ], det_results [:, 2 ] = det_results [:, 0 ]* ratio [1 ], det_results [:, 2 ]* ratio [1 ]
337- det_results [:, 1 ], det_results [:, 3 ] = det_results [:, 1 ]* ratio [0 ], det_results [:, 3 ]* ratio [0 ]
338-
339331 """step 1. filter results and init tracks"""
340332
341333 # filter small area bboxs
342334 if self .filter_small_area :
343335 small_indicies = det_results [:, 2 ]* det_results [:, 3 ] > 50
344336 det_results = det_results [small_indicies ]
345337
346- # run NMS
347- if self .NMS :
348- # NOTE: Note nms need tlbr format
349- nms_indices = nms (torch .from_numpy (STrack .xywh2tlbr (det_results [:, :4 ])), torch .from_numpy (det_results [:, 4 ]),
350- self .opts .nms_thresh )
351- det_results = det_results [nms_indices .numpy ()]
352-
353338 # cal high and low indicies
354339 det_high_indicies = det_results [:, 4 ] >= self .det_thresh
355340 det_low_indicies = np .logical_and (np .logical_not (det_high_indicies ), det_results [:, 4 ] > self .low_conf_thresh )
@@ -358,19 +343,19 @@ def update(self, det_results, ori_img):
358343 det_high , det_low = det_results [det_high_indicies ], det_results [det_low_indicies ]
359344 if det_high .shape [0 ] > 0 :
360345 if self .use_apperance_model :
361- features = self .get_feature (STrack . xywh2tlbr ( det_high [:, :4 ]) , ori_img )
346+ features = self .get_feature (det_high [:, :4 ], ori_img )
362347 # detections: List[Strack]
363- D_high = [STrack (cls , STrack .xywh2tlwh ( xywh ), score , kalman_format = self .opts .kalman_format , feature = feature )
364- for (cls , xywh , score , feature ) in zip (det_high [:, - 1 ], det_high [:, :4 ], det_high [:, 4 ], features )]
348+ D_high = [STrack (cls , STrack .tlbr2tlwh ( tlbr ), score , kalman_format = self .opts .kalman_format , feature = feature )
349+ for (cls , tlbr , score , feature ) in zip (det_high [:, - 1 ], det_high [:, :4 ], det_high [:, 4 ], features )]
365350 else :
366- D_high = [STrack (cls , STrack .xywh2tlwh ( xywh ), score , kalman_format = self .opts .kalman_format )
367- for (cls , xywh , score ) in zip (det_high [:, - 1 ], det_high [:, :4 ], det_high [:, 4 ])]
351+ D_high = [STrack (cls , STrack .tlbr2tlwh ( tlbr ), score , kalman_format = self .opts .kalman_format )
352+ for (cls , tlbr , score ) in zip (det_high [:, - 1 ], det_high [:, :4 ], det_high [:, 4 ])]
368353 else :
369354 D_high = []
370355
371356 if det_low .shape [0 ] > 0 :
372- D_low = [STrack (cls , STrack .xywh2tlwh ( xywh ), score , kalman_format = self .opts .kalman_format )
373- for (cls , xywh , score ) in zip (det_low [:, - 1 ], det_low [:, :4 ], det_low [:, 4 ])]
357+ D_low = [STrack (cls , STrack .tlbr2tlwh ( tlbr ), score , kalman_format = self .opts .kalman_format )
358+ for (cls , tlbr , score ) in zip (det_high [:, - 1 ], det_high [:, :4 ], det_high [:, 4 ])]
374359 else :
375360 D_low = []
376361
0 commit comments