Optimize one-to-one match computation #7
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.
Problem: Repeating same computation when calling one-to-one match.
Especially slow when each individual GT/submission file has large number of bounding boxes (>100). The first 2 conditions of the
one_to_one_match
only need to be computed once.How to reproduce:
gt.zip
in which each.txt
file contains large number of bounding boxes.subm.zip
can also contains large number of bounding boxes.python script.py -g="gt.zip" -s="subm.zip" [--E2E] [-t 4]
Output (average bbox per gt/subm: 100~):
After optimization:
Explanation & Solutions: the
one_to_one_match
is calledn_gt * n_sumb
times.The first condition relies only on the row (always sum all second axis) while the second condition relies only on the col (always sum the first axis). All of which can just be computed once and reuse for all the
n_gt * n_sumb
iterations.We can immediately filter out the indices that doesn't meet the first & second condition and iterate through those that still possible for one-to-one match (and check with the third condition)