perf(eval): simplify fixed distractor membership - #576
Open
JESUSROYETH wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_distractor_ground_truth_maskruns once per ground-truth frame, but the membership set is always the same four MOT17 classes:(2, 7, 8, 12).np.isindoesn'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, andpre-commit run --all-filesis 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.
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.