def calculate_iou(self, pred_masks, labels): best_ious = [] for image_masks, gt_image_masks in zip(pred_masks, labels): ious = mask_iou(image_masks, gt_image_masks) best_ious.append(self.xp.max(ious, axis=1)) return best_ious
def test_mask_iou_invalid(self): with self.assertRaises(IndexError): mask_iou(self.mask_a, self.mask_b)
def check(self, mask_a, mask_b, expected): iou = mask_iou(mask_a, mask_b) self.assertIsInstance(iou, type(expected)) np.testing.assert_equal(cuda.to_cpu(iou), cuda.to_cpu(expected))