Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
change bbox_overlap --> bbox_iou
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyu2172 committed May 22, 2017
1 parent 7b29911 commit a9b2c19
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion chainercv/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from chainercv.utils.bbox.bbox_overlap import bbox_overlap # NOQA
from chainercv.utils.bbox.bbox_iou import bbox_iou # NOQA
from chainercv.utils.bbox.non_maximum_suppression import non_maximum_suppression # NOQA
from chainercv.utils.download import cached_download # NOQA
from chainercv.utils.download import extractall # NOQA
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from chainer import cuda


def bbox_overlap(bbox_a, bbox_b):
"""Calculate Jaccard overlap between bounding boxes.
def bbox_iou(bbox_a, bbox_b):
"""Calculate the Intersection of Unions (IoUs) between bounding boxes.
Jaccard overlap is calculated as a ratio of area of the intersection
IoU is calculated as a ratio of area of the intersection
and area of the union.
This function accepts both :obj:`numpy.ndarray` and :obj:`cupy.ndarray` as
Expand All @@ -23,7 +23,7 @@ def bbox_overlap(bbox_a, bbox_b):
Returns:
array:
An array whose shape is :math:`(N, K)`. \
An element at index :math:`(n, k)` contains overlap between \
An element at index :math:`(n, k)` contains IoUs between \
:math:`n` th bounding box in :obj:`bbox_a` and :math:`k` th bounding \
box in :obj:`bbox_b`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from chainer import testing
from chainer.testing import attr

from chainercv.utils import bbox_overlap
from chainercv.utils import bbox_iou


@testing.parameterize(
Expand All @@ -29,21 +29,21 @@
'expected': np.zeros((0, 1), dtype=np.float32)
},
)
class TestBboxOverlap(unittest.TestCase):
class TestBboxIou(unittest.TestCase):

def check(self, bbox_a, bbox_b, expected):
overlap = bbox_overlap(bbox_a, bbox_b)
iou = bbox_iou(bbox_a, bbox_b)

self.assertIsInstance(overlap, type(expected))
self.assertIsInstance(iou, type(expected))
np.testing.assert_equal(
cuda.to_cpu(overlap),
cuda.to_cpu(iou),
cuda.to_cpu(expected))

def test_bbox_overlap_cpu(self):
def test_bbox_iou_cpu(self):
self.check(self.bbox_a, self.bbox_b, self.expected)

@attr.gpu
def test_bbox_overlap_gpu(self):
def test_bbox_iou_gpu(self):
self.check(
cuda.to_gpu(self.bbox_a),
cuda.to_gpu(self.bbox_b),
Expand All @@ -56,14 +56,14 @@ def test_bbox_overlap_gpu(self):
{'bbox_a': [[0, 0, 8, 8]], 'bbox_b': [[1, 1, 9]]},
{'bbox_a': [[0, 0, 8, 8]], 'bbox_b': [[1, 1, 9, 9, 10]]}
)
class TestBboxOverlapInvalidShape(unittest.TestCase):
class TestBboxIouInvalidShape(unittest.TestCase):

def test_bbox_overlap_invalid(self):
def test_bbox_iou_invalid(self):
bbox_a = np.array(self.bbox_a, dtype=np.float32)
bbox_b = np.array(self.bbox_b, dtype=np.float32)

with self.assertRaises(IndexError):
bbox_overlap(bbox_a, bbox_b)
bbox_iou(bbox_a, bbox_b)


testing.run_module(__name__, __file__)

0 comments on commit a9b2c19

Please sign in to comment.