Skip to content

Performance: Vectorize inner loop in _match_predictions using NumPy masking#570

Open
Vo1denz wants to merge 1 commit intoJdeRobot:masterfrom
Vo1denz:issue_569_vectorize_match_predictions
Open

Performance: Vectorize inner loop in _match_predictions using NumPy masking#570
Vo1denz wants to merge 1 commit intoJdeRobot:masterfrom
Vo1denz:issue_569_vectorize_match_predictions

Conversation

@Vo1denz
Copy link
Copy Markdown

@Vo1denz Vo1denz commented Apr 28, 2026

Closes #569

What was changed

Replaced the Python inner loop in _match_predictions with NumPy boolean
masking + np.argmax to 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

  • All 9 detection metric tests pass
  • Full suite: 44 passed, 2 failed (pre-existing Open3D failures, unrelated)

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.

@Vo1denz
Copy link
Copy Markdown
Author

Vo1denz commented Apr 28, 2026

Opened PR #570 for this. Happy to make any changes based on feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: Vectorize inner loop in _match_predictions using NumPy masking

1 participant