Skip to content

Commit

Permalink
fixed boxutils test
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov721 committed Sep 25, 2024
1 parent 7f12681 commit 9cf119e
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions tests/unittests/test_utils/test_boxutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,30 @@ def test_bbox2dist():
assert distance.shape == bbox.shape


@pytest.mark.parametrize("iou_type", ["none", "giou", "diou", "ciou", "siou"])
def test_bbox_iou(iou_type: IoUType):
for format in ["xyxy", "cxcywh", "xywh"]:
bbox1 = generate_random_bboxes(5, 640, 640, format)
if iou_type == "siou":
bbox2 = generate_random_bboxes(5, 640, 640, format)
else:
bbox2 = generate_random_bboxes(8, 640, 640, format)

iou = bbox_iou(
bbox1,
bbox2,
bbox_format=format, # type: ignore
iou_type=iou_type,
)

assert iou.shape == (bbox1.shape[0], bbox2.shape[0])
if iou_type == "none":
min = 0
else:
min = -1.5
assert iou.min() >= min and iou.max() <= 1
@pytest.mark.parametrize("iou_type", ["none", "giou", "diou", "ciou"])
@pytest.mark.parametrize("format", ["xyxy", "xywh", "cxcywh"])
def test_bbox_iou(
iou_type: IoUType, format: Literal["xyxy", "xywh", "cxcywh"]
):
bbox1 = generate_random_bboxes(5, 640, 640, format)
if iou_type == "siou":
bbox2 = generate_random_bboxes(5, 640, 640, format)

Check warning on line 72 in tests/unittests/test_utils/test_boxutils.py

View check run for this annotation

Codecov / codecov/patch

tests/unittests/test_utils/test_boxutils.py#L72

Added line #L72 was not covered by tests
else:
bbox2 = generate_random_bboxes(8, 640, 640, format)

iou = bbox_iou(
bbox1,
bbox2,
bbox_format=format, # type: ignore
iou_type=iou_type,
)

assert iou.shape == (bbox1.shape[0], bbox2.shape[0])
if iou_type == "none":
min = 0
else:
min = -1.5
assert iou.min() >= min and iou.max() <= 1

if iou_type == "none":
with pytest.raises(ValueError):
Expand Down

0 comments on commit 9cf119e

Please sign in to comment.