(self)
| 148 | |
| 149 | class 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 | |
| 176 | class TestBoxes(unittest.TestCase): |
nothing calls this directly
no test coverage detected