1- from typing import List , Optional , Tuple
1+ from typing import List , Tuple
22
33import numpy as np
44
1111class STrack (BaseTrack ):
1212 shared_kalman = KalmanFilter ()
1313
14- def __init__ (self , tlwh , score , class_ids , mask : Optional [ np . array ] = None ):
14+ def __init__ (self , tlwh , score , class_ids ):
1515 # wait activate
1616 self ._tlwh = np .asarray (tlwh , dtype = np .float32 )
1717 self .kalman_filter = None
@@ -21,7 +21,6 @@ def __init__(self, tlwh, score, class_ids, mask: Optional[np.array] = None):
2121 self .score = score
2222 self .class_ids = class_ids
2323 self .tracklet_len = 0
24- self .mask = mask
2524
2625 def predict (self ):
2726 mean_state = self .mean .copy ()
@@ -75,7 +74,6 @@ def re_activate(self, new_track, frame_id, new_id=False):
7574 if new_id :
7675 self .track_id = self .next_id ()
7776 self .score = new_track .score
78- self .mask = new_track .mask
7977
8078 def update (self , new_track , frame_id ):
8179 """
@@ -97,8 +95,6 @@ def update(self, new_track, frame_id):
9795
9896 self .score = new_track .score
9997
100- self .mask = new_track .mask
101-
10298 @property
10399 def tlwh (self ):
104100 """Get current position in bounding box format `(top left x, top left y,
@@ -235,8 +231,9 @@ def update_with_detections(self, detections: Detections) -> Detections:
235231 ... )
236232 ```
237233 """
234+
238235 tracks = self .update_with_tensors (
239- tensors = detections2boxes (detections = detections ), masks = detections . mask
236+ tensors = detections2boxes (detections = detections )
240237 )
241238 detections = Detections .empty ()
242239 if len (tracks ) > 0 :
@@ -252,22 +249,17 @@ def update_with_detections(self, detections: Detections) -> Detections:
252249 detections .confidence = np .array (
253250 [t .score for t in tracks ], dtype = np .float32
254251 )
255- detections .mask = np .array ([t .mask for t in tracks ], dtype = bool )
256-
257252 else :
258253 detections .tracker_id = np .array ([], dtype = int )
259254
260255 return detections
261256
262- def update_with_tensors (
263- self , tensors : np .ndarray , masks : Optional [np .array ] = None
264- ) -> List [STrack ]:
257+ def update_with_tensors (self , tensors : np .ndarray ) -> List [STrack ]:
265258 """
266259 Updates the tracker with the provided tensors and returns the updated tracks.
267260
268261 Parameters:
269262 tensors: The new tensors to update with.
270- masks: The new masks associated to new tensors
271263
272264 Returns:
273265 List[STrack]: Updated tracks.
@@ -289,12 +281,6 @@ def update_with_tensors(
289281 inds_second = np .logical_and (inds_low , inds_high )
290282 dets_second = bboxes [inds_second ]
291283 dets = bboxes [remain_inds ]
292- if masks is not None :
293- masks_keep = masks [remain_inds ]
294- masks_second = masks [inds_second ]
295- else :
296- masks_keep = np .array ([None ] * len (remain_inds ))
297- masks_second = np .array ([None ] * len (inds_second ))
298284 scores_keep = scores [remain_inds ]
299285 scores_second = scores [inds_second ]
300286
@@ -304,10 +290,8 @@ def update_with_tensors(
304290 if len (dets ) > 0 :
305291 """Detections"""
306292 detections = [
307- STrack (STrack .tlbr_to_tlwh (tlbr ), s , c , m )
308- for (tlbr , s , c , m ) in zip (
309- dets , scores_keep , class_ids_keep , masks_keep
310- )
293+ STrack (STrack .tlbr_to_tlwh (tlbr ), s , c )
294+ for (tlbr , s , c ) in zip (dets , scores_keep , class_ids_keep )
311295 ]
312296 else :
313297 detections = []
@@ -347,10 +331,8 @@ def update_with_tensors(
347331 if len (dets_second ) > 0 :
348332 """Detections"""
349333 detections_second = [
350- STrack (STrack .tlbr_to_tlwh (tlbr ), s , c , m )
351- for (tlbr , s , c , m ) in zip (
352- dets_second , scores_second , class_ids_second , masks_second
353- )
334+ STrack (STrack .tlbr_to_tlwh (tlbr ), s , c )
335+ for (tlbr , s , c ) in zip (dets_second , scores_second , class_ids_second )
354336 ]
355337 else :
356338 detections_second = []
0 commit comments