Skip to content

perf(eval): simplify fixed distractor membership - #576

Open
JESUSROYETH wants to merge 1 commit into
roboflow:developfrom
JESUSROYETH:perf/mot-distractor-membership
Open

perf(eval): simplify fixed distractor membership#576
JESUSROYETH wants to merge 1 commit into
roboflow:developfrom
JESUSROYETH:perf/mot-distractor-membership

Conversation

@JESUSROYETH

Copy link
Copy Markdown
Contributor

_distractor_ground_truth_mask runs once per ground-truth frame, but the membership set is always the same four MOT17 classes: (2, 7, 8, 12). np.isin doesn't know that, it still runs its generic dispatch and setup for each of those small arrays every time.

So this replaces that call with four equality expressions. The tuple stays as the single source for the class values, and the mask dtype and shape stay unchanged.

Validation

The existing tests from #466 already cover each distractor class, the downstream suppression of its matched tracker detection, non-distractor ignored rows, empty frames and multi-frame input. All 10 MOT preprocessing tests pass without changing those tests.

The mask bytes are exact on 2,222 seeded adversarial rows, including the integer limits, and on all 97,493 MOT17 validation GT rows. I also compared develop against itself before checking this patch.

Prepared arrays and the complete per-sequence CLEAR/HOTA/Identity payloads have the same bit-level digest before and after, on 7 MOT17, 25 DanceTrack and 45 SportsMOT sequences.

pytest -m 'not integration' passes with 1,564 tests, all 4 evaluation integration tests pass, and pre-commit run --all-files is clean.

Performance

CPU-only, Python 3.12.3 / NumPy 1.26.4. Files are loaded before timing and each run includes MOT preparation plus CLEAR/HOTA/Identity. Run order alternates between develop and the patch, and garbage collection runs before each sample so it doesn't add noise.

dataset sequences / frames develop median [range] this patch median [range] delta paired wins
MOT17 7 / 2,652 142.29 µs/frame [139.48, 160.08] 124.72 µs/frame [122.66, 131.71] -12.35% 15/15
DanceTrack 25 / 25,508 102.27 µs/frame [96.06, 104.01] 87.50 µs/frame [86.18, 92.32] -14.44% 10/10
SportsMOT 45 / 26,970 105.31 µs/frame [104.85, 107.78] 91.05 µs/frame [90.28, 93.66] -13.55% 10/10

Open PRs #561 and #562 also touch mot.py#561 in the loader, #562 in the duplicate-ID validation. This patch only touches one line-area, so it applies cleanly on both current heads.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes MOT distractor-class filtering by replacing generic np.isin dispatch with fixed equality checks.

Changes:

  • Reuses the existing distractor-class tuple.
  • Preserves mask shape, dtype, and behavior while reducing per-frame overhead.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Borda Borda added the enhancement New feature or request label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants