@@ -328,28 +328,13 @@ def update(self, det_results, ori_img):
328
328
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)
329
329
removed_stracks = []
330
330
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
-
339
331
"""step 1. filter results and init tracks"""
340
332
341
333
# filter small area bboxs
342
334
if self .filter_small_area :
343
335
small_indicies = det_results [:, 2 ]* det_results [:, 3 ] > 50
344
336
det_results = det_results [small_indicies ]
345
337
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
-
353
338
# cal high and low indicies
354
339
det_high_indicies = det_results [:, 4 ] >= self .det_thresh
355
340
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):
358
343
det_high , det_low = det_results [det_high_indicies ], det_results [det_low_indicies ]
359
344
if det_high .shape [0 ] > 0 :
360
345
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 )
362
347
# 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 )]
365
350
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 ])]
368
353
else :
369
354
D_high = []
370
355
371
356
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 ])]
374
359
else :
375
360
D_low = []
376
361
0 commit comments