Fix masks_to_boxes for empty masks and vectorize for performance#9347
Fix masks_to_boxes for empty masks and vectorize for performance#9347raimbekovm wants to merge 2 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9347
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 0f8f3f1 with merge base 6acedba ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@raimbekovm Thanks a lot for your contribution! Could you please separate this into two PRs? |
|
Thanks for the feedback! I've split this into two PRs as suggested:
Closing this one. |
Fixes #9346
masks_to_boxesraisesRuntimeErrorwhen a mask is all zeros becausetorch.min/maxon empty tensor requires explicit dim.This PR:
[0, 0, 0, 0]bounding boxesThis is based on the approach from #8194 but fixes the empty mask handling issue that was identified there (the vectorized argmax returns
[0, 0, W-1, H-1]for empty masks instead of[0, 0, 0, 0]). We detect empty masks explicitly and set their boxes to zeros.