Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix rbbox_overlaps error #620

Merged
merged 3 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mmrotate/structures/bbox/bbox_overlaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def rbbox_overlaps(bboxes1: Tensor,
clamped_bboxes1[:, 2:4].clamp_(min=1e-3)
clamped_bboxes2[:, 2:4].clamp_(min=1e-3)

# resolve `rbbox_overlaps` abnormal when coordinate value is too large.
# TODO: fix in mmcv
clamped_bboxes1[:, :2].clamp_(min=-1e7, max=1e7)
clamped_bboxes2[:, :2].clamp_(min=-1e7, max=1e7)

return box_iou_rotated(clamped_bboxes1, clamped_bboxes2, mode, is_aligned)


Expand Down Expand Up @@ -89,4 +94,9 @@ def fake_rbbox_overlaps(bboxes1: RotatedBoxes,
clamped_bboxes1[:, 2:4].clamp_(min=1e-3)
clamped_bboxes2[:, 2:4].clamp_(min=1e-3)

# resolve `rbbox_overlaps` abnormal when coordinate value is too large.
# TODO: fix in mmcv
clamped_bboxes1[:, :2].clamp_(min=-1e7, max=1e7)
clamped_bboxes2[:, :2].clamp_(min=-1e7, max=1e7)

return box_iou_rotated(clamped_bboxes1, clamped_bboxes2, mode, is_aligned)
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ def test_rbbox_overlaps(self):
self.assertTrue(torch.all(ious >= -1) and torch.all(ious <= 1))
self.assertEqual(ious.size(), (bboxes1.size(0), bboxes2.size(0)))

# test boundary condition
bboxes1 = torch.FloatTensor([[-8.3e8, 1.4e8, 2.0e9, 3.3e1, -1.7e-1],
[8.3e8, -1.4e8, 2.0e9, 3.3e1, -1.7e-1],
[-8.3e8, -1.4e8, 2.0e9, 3.3e9, -1.7e-1]])
bboxes2 = torch.FloatTensor([[160.0, 152.0, 2.54, 13.13, -1.5708],
[128.0, 121.0, 2.75, 17.0, -1.5708],
[136.0, 82.5, 5.8, 2.16, -1.22]])
ious = rbbox_overlaps(bboxes1, bboxes2, 'iou')
self.assertTrue(torch.all(ious >= -1) and torch.all(ious <= 1))

def test_fake_rbbox_overlaps_2d(self):
overlap = FakeRBboxOverlaps2D()
bboxes1, num_bbox = self._construct_rbbox()
Expand Down