Skip to content

Commit 606231b

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent 3084c1b commit 606231b

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

docs/learn/state-estimators.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ We can also benchmark the trackers using the different State Estimators and we g
155155
- With defaults parameters in Soccernet dataset, SORT tracker with XYXYStateEstimator has ~5% more HOTA than using XCYC,
156156
- In SportsMOT, for OC-SORT and ByteTrack, the StateEstimator doesn't affect the performance, while for SORT XYXYStateEstimator gives a small advantage of ~2% HOTA with default parameters and 0.4% when tuning both.
157157

158-
159158
But lets visualize where these differences are, here is an example where using XCYCSR State Estimator associates an occluded track correctly, while using XYXY changes the ID:
160159

161160
<div style="display: flex; justify-content: center;">

trackers/core/botsort/tracker.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class BoTSORTTracker(BaseTracker):
7272
int(frame_rate / 30.0 * lost_track_buffer)
7373
to maintain consistent “seconds” worth of buffer across different FPS.
7474
"""
75+
7576
def __init__(
7677
self,
7778
lost_track_buffer: int = 30,
@@ -179,10 +180,7 @@ def update(
179180
for track in self.tracks:
180181
if track.time_since_update > 1:
181182
lost_tracks.append(track)
182-
elif (
183-
track.number_of_successful_updates
184-
>= self.minimum_consecutive_frames
185-
):
183+
elif track.number_of_successful_updates >= self.minimum_consecutive_frames:
186184
confirmed_tracks.append(track)
187185
else:
188186
unconfirmed_tracks.append(track)
@@ -208,8 +206,7 @@ def update(
208206
track = strack_pool[row]
209207
track.update(high_boxes[col])
210208
if (
211-
track.number_of_successful_updates
212-
>= self.minimum_consecutive_frames
209+
track.number_of_successful_updates >= self.minimum_consecutive_frames
213210
and track.tracker_id == -1
214211
):
215212
track.tracker_id = BoTSORTTracklet.get_next_tracker_id()
@@ -233,8 +230,7 @@ def update(
233230
track = remaining_tracked[row]
234231
track.update(low_boxes[col])
235232
if (
236-
track.number_of_successful_updates
237-
>= self.minimum_consecutive_frames
233+
track.number_of_successful_updates >= self.minimum_consecutive_frames
238234
and track.tracker_id == -1
239235
):
240236
track.tracker_id = BoTSORTTracklet.get_next_tracker_id()

trackers/core/botsort/tracklet.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,36 @@ def _set_scale_aware_noise(
6969

7070
Q = np.diag(
7171
[
72-
(sp * w) ** 2, (sp * h) ** 2, (sp * w) ** 2, (sp * h) ** 2,
73-
(sv * w) ** 2, (sv * h) ** 2, (sv * w) ** 2, (sv * h) ** 2,
72+
(sp * w) ** 2,
73+
(sp * h) ** 2,
74+
(sp * w) ** 2,
75+
(sp * h) ** 2,
76+
(sv * w) ** 2,
77+
(sv * h) ** 2,
78+
(sv * w) ** 2,
79+
(sv * h) ** 2,
7480
]
7581
)
7682
R = np.diag(
7783
[
78-
(sm * w) ** 2, (sm * h) ** 2, (sm * w) ** 2, (sm * h) ** 2,
84+
(sm * w) ** 2,
85+
(sm * h) ** 2,
86+
(sm * w) ** 2,
87+
(sm * h) ** 2,
7988
]
8089
)
8190

8291
if initial:
8392
P = np.diag(
8493
[
85-
(2 * sp * w) ** 2, (2 * sp * h) ** 2,
86-
(2 * sp * w) ** 2, (2 * sp * h) ** 2,
87-
(10 * sv * w) ** 2, (10 * sv * h) ** 2,
88-
(10 * sv * w) ** 2, (10 * sv * h) ** 2,
94+
(2 * sp * w) ** 2,
95+
(2 * sp * h) ** 2,
96+
(2 * sp * w) ** 2,
97+
(2 * sp * h) ** 2,
98+
(10 * sv * w) ** 2,
99+
(10 * sv * h) ** 2,
100+
(10 * sv * w) ** 2,
101+
(10 * sv * h) ** 2,
89102
]
90103
)
91104
self.state_estimator.set_kf_covariances(R=R, Q=Q, P=P)
@@ -142,7 +155,6 @@ def get_state_bbox(self) -> np.ndarray:
142155
"""Return the current bounding-box estimate in xyxy format."""
143156
return self.state_estimator.state_to_bbox()
144157

145-
146158
def apply_cmc(self, H: np.ndarray) -> None:
147159
"""Apply a 2×3 affine camera-motion transform **in place**.
148160
@@ -175,9 +187,7 @@ def apply_cmc(self, H: np.ndarray) -> None:
175187
kf.P = A @ kf.P @ A.T
176188

177189
@staticmethod
178-
def apply_cmc_batch(
179-
tracklets: Sequence[BoTSORTTracklet], H: np.ndarray
180-
) -> None:
190+
def apply_cmc_batch(tracklets: Sequence[BoTSORTTracklet], H: np.ndarray) -> None:
181191
"""Apply a 2×3 affine camera-motion transform to all tracklets at once.
182192
183193
Vectorised replacement for calling :meth:`apply_cmc` in a loop.
@@ -198,9 +208,7 @@ def apply_cmc_batch(
198208
dim = tracklets[0].state_estimator.kf.x.shape[0]
199209

200210
# Stack states (N, dim) and covariances (N, dim, dim)
201-
states = np.array(
202-
[trk.state_estimator.kf.x.reshape(-1) for trk in tracklets]
203-
)
211+
states = np.array([trk.state_estimator.kf.x.reshape(-1) for trk in tracklets])
204212
Ps = np.array([trk.state_estimator.kf.P for trk in tracklets])
205213

206214
# Batch-transform centre positions: x' = x @ R.T + t

trackers/core/botsort/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def get_alive_trackers(
4444
return alive_trackers
4545

4646

47-
def _fuse_score(
48-
iou_similarity: np.ndarray, scores: np.ndarray
49-
) -> np.ndarray:
47+
def _fuse_score(iou_similarity: np.ndarray, scores: np.ndarray) -> np.ndarray:
5048
"""Fuse IoU similarity matrix with detection confidence scores.
5149
5250
Following the original ByteTrack implementation, the IoU similarity is

0 commit comments

Comments
 (0)