Add `box_area_center` and `box_iou_center` functions for cxcywh format with tests
Related https://github.com/pytorch/vision/issues/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_center and box_iou_center functions, 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].
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8992
- :page_facing_up: Preview Python docs built from this PR
Note: Links to docs will display an error until the docs builds have been completed.
:x: 1 New Failure
As of commit 80d12de6a5c81d976f82104b8d1b8e60d8577a82 with merge base 97920a5210200e55cbab2929cb78cfcd918d3002 ():
NEW FAILURE - The following job has failed:
-
Docs / build / linux-job (gh)
At least one of the pre-conditions you specified did not hold
This comment was automatically generated by Dr. CI and updates every 15 minutes.
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 box_area, box_iou, and _box_inter_union. This should not change the logic behind your PR. Could you kindly review and let me know if this fits your needs before we merge? Thanks!
Hi @AntoineSimoulin,
Thanks for reviewing the PR.
These changes look great, and I’ve fixed a few small issues with them.
Since we now support the xywh format, I think we should also add tests for it.
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. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py