Add cxcywh and xywh format options for box_area and box_iou functions with tests#8992
Add cxcywh and xywh format options for box_area and box_iou functions with tests#8992AntoineSimoulin merged 23 commits intopytorch:mainfrom
cxcywh and xywh format options for box_area and box_iou functions with tests#8992Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8992
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 80d12de with merge base 97920a5 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torchvision/ops/boxes.py
Outdated
| return (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1]) | ||
|
|
||
|
|
||
| def box_area_center(boxes: Tensor) -> Tensor: |
There was a problem hiding this comment.
Thanks a lot for the PR and for the benchmarks @alperenunlu !
I agree with @AntoineSimoulin 's suggestion in #8961 (comment) to not expose the new _center() functions, and instead just add a new fmt (or in_fmt) parameter to the existing box_area() and box_iou() functions.
This will reduce surface area of the API, so it'll be easier to find for users, and easier for us to maintain as well!
For the rest I will let @AntoineSimoulin take a look
|
Hi @alperenunlu, thanks for your patience here. I went through the PR again and pushed some small changes. To simplify the code, I integrated all the logic specific to different formats directly to the |
|
Hi @AntoineSimoulin, Thanks for reviewing the PR. Since we now support the Overall, I’m very satisfied with the changes. |
|
Thanks @alperenunlu. I simplified the test case a bit to limit verbosity and added some tests for all formats. Will merge when all tests are passing! Thanks a lot for your time and the contribution. Sorry for the rather long review. Excited to see the change to be included in the future release! |
|
Hey @AntoineSimoulin! You merged this PR, but no labels were added. |
box_area_center and box_iou_center functions for cxcywh format with testscxcywh and xywh format options for box_area and box_iou functions with tests
Related #8961
This pull request introduces new utility functions for handling bounding boxes and adds corresponding tests. The main changes include the addition of
box_area_centerandbox_iou_centerfunctions, as well as comprehensive tests to ensure their correctness.New utility functions:
torchvision/ops/boxes.py: Addedbox_area_centerfunction to compute the area of bounding boxes specified by their center coordinates.torchvision/ops/boxes.py: Addedbox_iou_centerfunction to compute the intersection-over-union (IoU) for bounding boxes specified by their center coordinates.Documentation updates:
docs/source/ops.rst: Updated the documentation to includebox_area_centerandbox_iou_center.Test additions:
test/test_ops.py: AddedTestBoxAreaCenterclass with tests forbox_area_centerfunction.test/test_ops.py: AddedTestBoxIouCenterclass with tests forbox_iou_centerfunction.Module initialization:
torchvision/ops/__init__.py: Updated the module initialization to includebox_area_centerandbox_iou_center[1] [2].