Performance: Vectorize inner loop in _match_predictions using NumPy masking#570
Open
Vo1denz wants to merge 1 commit intoJdeRobot:masterfrom
Open
Performance: Vectorize inner loop in _match_predictions using NumPy masking#570Vo1denz wants to merge 1 commit intoJdeRobot:masterfrom
Vo1denz wants to merge 1 commit intoJdeRobot:masterfrom
Conversation
Author
|
Opened PR #570 for this. Happy to make any changes based on feedback. |
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.
Closes #569
What was changed
Replaced the Python inner loop in
_match_predictionswith NumPy booleanmasking +
np.argmaxto find the best GT match per prediction.Also added confidence-score-based sorting of predictions before matching
this is standard mAP practice where high-confidence predictions get first
pick of GT boxes.
Why
The IoU matrix was already computed in one NumPy call, but was being read
element-by-element inside a Python loop, N×M iterations per image.
The fix reduces this to N iterations, each O(M) in NumPy.
How it was tested
Note on AI assistance
Parts of this implementation were developed with AI.
The code has been reviewed, understood, and verified against the existing
test suite.