MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / test_pairwise_iou

Method test_pairwise_iou

tests/structures/test_boxes.py:150–173  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148
149class TestBoxIOU(unittest.TestCase):
150 def test_pairwise_iou(self):
151 boxes1 = torch.tensor([[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]])
152
153 boxes2 = torch.tensor(
154 [
155 [0.0, 0.0, 1.0, 1.0],
156 [0.0, 0.0, 0.5, 1.0],
157 [0.0, 0.0, 1.0, 0.5],
158 [0.0, 0.0, 0.5, 0.5],
159 [0.5, 0.5, 1.0, 1.0],
160 [0.5, 0.5, 1.5, 1.5],
161 ]
162 )
163
164 expected_ious = torch.tensor(
165 [
166 [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
167 [1.0, 0.5, 0.5, 0.25, 0.25, 0.25 / (2 - 0.25)],
168 ]
169 )
170
171 ious = pairwise_iou(Boxes(boxes1), Boxes(boxes2))
172
173 self.assertTrue(torch.allclose(ious, expected_ious))
174
175
176class TestBoxes(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

pairwise_iouFunction · 0.90
BoxesClass · 0.90

Tested by

no test coverage detected