Skip to content

Commit 14cb36c

Browse files
Bordaclaude
andcommitted
add conf_cost_weight to stage-1 assignment (default=0.0 disabled)
- Confidence boost in Hungarian cost: solver_iou *= (1 + w * conf[det]) - Neutral at all tested defaults (0.0–0.5); added to Optuna search space [0.0, 1.0] - IDSW improved 297→293 at w=0.3 but HOTA regressed; w=0.1 exactly neutral --- Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent 91ec453 commit 14cb36c

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

autotrack/default_config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"q_miss_alpha": 0.282,
1717
"max_interpolation_gap": 32,
1818
"p_reset_threshold": 26,
19-
"oru_threshold": 14
19+
"oru_threshold": 14,
20+
"conf_cost_weight": 0.0
2021
},
2122
"sort": {
2223
"lost_track_buffer": 30,
@@ -34,4 +35,4 @@
3435
"delta_t": 3,
3536
"max_interpolation_gap": 0
3637
}
37-
}
38+
}

autotrack/optimize_tracking.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def _build_tracker(params: dict, tracker_name: str):
185185
stage2_iou_threshold=params["stage2_iou_threshold"],
186186
iou_age_weight=params["iou_age_weight"],
187187
high_conf_det_threshold=params["high_conf_det_threshold"],
188+
conf_cost_weight=params.get("conf_cost_weight", 0.0),
188189
)
189190
if tracker_name == "sort":
190191
from trackers import SORTTracker

autotrack/search_space.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
"type": "int",
8888
"low": 0,
8989
"high": 15
90+
},
91+
"conf_cost_weight": {
92+
"type": "float",
93+
"low": 0.0,
94+
"high": 1.0
9095
}
9196
},
9297
"sort": {

trackers/core/bytetrack/tracker.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def __init__(
8282
stage2_iou_threshold: float = 0.05,
8383
iou_age_weight: float = 0.03,
8484
high_conf_det_threshold: float = 0.6,
85+
conf_cost_weight: float = 0.0,
8586
) -> None:
8687
# Calculate maximum frames without update based on lost_track_buffer and
8788
# frame_rate. This scales the buffer based on the frame rate to ensure
@@ -93,6 +94,7 @@ def __init__(
9394
self.iou_age_weight = iou_age_weight
9495
self.track_activation_threshold = track_activation_threshold
9596
self.high_conf_det_threshold = high_conf_det_threshold
97+
self.conf_cost_weight = conf_cost_weight
9698
self.tracks: list[ByteTrackKalmanBoxTracker] = []
9799

98100
def update(
@@ -162,6 +164,14 @@ def update(
162164
else:
163165
solver_iou = iou_matrix
164166

167+
# Confidence boost: scale up solver IoU for higher-confidence detections
168+
# so the Hungarian assignment prefers confident detections over uncertain
169+
# ones when IoU values are close. The boost only affects ranking; the
170+
# threshold gate still uses raw IoU so valid matches are never blocked.
171+
if self.conf_cost_weight > 0 and solver_iou.size > 0 and len(high_indices) > 0:
172+
conf_boost = 1.0 + self.conf_cost_weight * confidences[high_indices]
173+
solver_iou = solver_iou * conf_boost[np.newaxis, :]
174+
165175
matched, unmatched_tracks, unmatched_high = self._get_associated_indices(
166176
solver_iou, self.minimum_iou_threshold, raw_similarity=iou_matrix
167177
)
@@ -259,7 +269,9 @@ def _get_associated_indices(
259269
unmatched_detections = set(range(n_detections))
260270

261271
# Use raw similarity for threshold gating when available
262-
thresh_matrix = raw_similarity if raw_similarity is not None else similarity_matrix
272+
thresh_matrix = (
273+
raw_similarity if raw_similarity is not None else similarity_matrix
274+
)
263275

264276
if n_tracks > 0 and n_detections > 0:
265277
row_indices, col_indices = linear_sum_assignment(

0 commit comments

Comments
 (0)