def test_multi_label(self):
        gt = make_representation("1 0 0 5 5; 0 9 9 10 10", is_ground_truth=True)
        pred = make_representation("1 1 0 0 5 5; 0.8 0 7 7 8 8")
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 1, overlap_evaluator)[:2]
        assert tp.shape[0] == 1
        assert tp[0] == 1
        assert fp[0] == 0

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp.shape[0] == 1
        assert tp[0] == 0
        assert fp[0] == 1
Пример #2
0
    def test_single_non_overlap(self):
        gt = make_representation("0 5 5 10 10", is_ground_truth=True)
        pred = make_representation("0 0 0 5 5", score=1)
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp[0] == 0
        assert fp[0] == 1
Пример #3
0
    def test_multiple_detections(self):
        gt = make_representation("0 0 0 5 5", is_ground_truth=True)
        pred = make_representation("1 0 0 0 5 5; 0.9 0 0 0 5 5")
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp[0] == 1
        assert tp[1] == 0
Пример #4
0
    def test_single_non_overlap_ignored(self):
        gt = make_representation("0 5 5 10 10", is_ground_truth=True)
        pred = make_representation("0 0 0 5 5", score=1)
        pred[0].metadata['difficult_boxes'] = [0]
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp[0] == 0
        assert fp[0] == 0
Пример #5
0
    def test_false_negative(self):
        gt = make_representation("0 0 0 5 5; 0 1 1 6 6", is_ground_truth=True)
        pred = make_representation("0 0 0 5 5", score=1)
        overlap_evaluator = IOU({})

        tp, fp, _, ngt = bbox_match(gt, pred, 0, overlap_evaluator)[:4]
        assert tp[0] == 1
        assert tp.shape[0] == 1
        assert ngt == 2
Пример #6
0
    def test_multiple(self):
        gt = make_representation("0 0 0 5 5; 0 7 7 8 8", is_ground_truth=True)
        pred = make_representation("0 0 0 5 5; 0 7 7 8 8", score=1)
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp[0] == 1
        assert tp[1] == 1
        assert fp[0] == 0
        assert fp[0] == 0
    def test_single_difficult_non_overlap(self):
        gt = make_representation("0 5 5 10 10", is_ground_truth=True)
        gt[0].metadata['difficult_boxes'] = [0]
        pred = make_representation("0 0 0 5 5", score=1)
        overlap_evaluator = IOU({})

        tp, fp, _, n = bbox_match(gt, pred, 0, overlap_evaluator)
        assert n == 0
        assert tp[0] == 0
        assert fp[0] == 1
Пример #8
0
    def test_single(self):
        gt = "0 0 0 5 5"
        pred = "0 0 0 5 5"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        overlap_evaluator = IOU({})

        tp, fp = bbox_match(gt, pred, 0, overlap_evaluator)[:2]
        assert tp[0] == 1
        assert fp[0] == 0
    def test_no_annotations(self):
        gt = "1 0 0 5 5"
        pred = "0 0 0 5 5"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        overlap_evaluator = IOU({})

        tp, fp, _, _ = bbox_match(gt, pred, 0, overlap_evaluator)
        assert tp[0] == 0
        assert fp[0] == 1
    def test_multi_image(self):
        gt = make_representation(["0 0 0 5 5", "0 0 0 5 5"],
                                 is_ground_truth=True)
        pred = make_representation(["0 0 0 5 5", "0 0 0 5 5"], score=1)
        overlap_evaluator = IOU({})

        tp, fp, _, _ = bbox_match(gt, pred, 0, overlap_evaluator)
        assert tp[0] == 1
        assert tp[1] == 1
        assert fp[0] == 0
        assert fp[1] == 0
    def test_multiple_2(self):
        gt = make_representation("0 0 0 5 5; 0 9 9 10 10",
                                 is_ground_truth=True)
        pred = make_representation("1 0 0 0 5 5; 0.8 0 7 7 8 8")
        overlap_evaluator = IOU({})

        tp, fp, _, _ = bbox_match(gt, pred, 0, overlap_evaluator)
        assert tp[0] == 1
        assert tp[1] == 0
        assert fp[0] == 0
        assert fp[1] == 1
Пример #12
0
    def test_no_predictions(self):
        gt = "0 0 0 5 5"
        pred = "1 0 0 5 5"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        overlap_evaluator = IOU({})

        tp, fp, _, n = bbox_match(gt, pred, 0, overlap_evaluator)[:4]
        assert n == 1
        assert len(tp) == 0
        assert len(fp) == 0
    def test_single_with_ignored_tp(self):
        gt = "0 0 0 5 5"
        pred = "0 0 0 5 5"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        pred[0].metadata['difficult_boxes'] = [0]
        overlap_evaluator = IOU({})

        tp, fp, _, _ = bbox_match(gt, pred, 0, overlap_evaluator)
        assert tp[0] == 0
        assert fp[0] == 0
    def test_multiple_detections_with_not_ignore_difficult(self):
        gt = make_representation("0 0 0 5 5", is_ground_truth=True)
        pred = make_representation("1 0 0 0 5 5; 0.9 0 0 0 5 5")
        gt[0].metadata['difficult_boxes'] = [0]
        overlap_evaluator = IOU({})

        tp, fp, _, n = bbox_match(gt, pred, 0, overlap_evaluator, ignore_difficult=False)[:4]
        assert n == 1
        assert tp[0] == 1
        assert tp[1] == 0
        assert fp[0] == 0
        assert fp[1] == 1
    def test_single_with_not_ignore_difficult(self):
        gt = "0 0 0 5 5"
        pred = "0 0 0 5 5"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        gt[0].metadata['difficult_boxes'] = [0]
        overlap_evaluator = IOU({})

        tp, fp, _, n = bbox_match(gt, pred, 0, overlap_evaluator, ignore_difficult=False)[:4]
        assert n == 1
        assert tp[0] == 1
        assert fp[0] == 0
Пример #16
0
    def test_iou_zero_union(self):
        gt = "0 0 0 0 0"
        pred = "0 0 0 0 0"

        gt = make_representation(gt, is_ground_truth=True)
        pred = make_representation(pred, score=1)
        overlap_evaluator = IOA({})

        with pytest.warns(None) as warnings:
            tp, fp, _, n = bbox_match(gt, pred, 0, overlap_evaluator)[:4]
            assert len(warnings) == 0
            assert n == 1
            assert tp[0] == 0
            assert fp[0] == 1