add test_evaluate_detection_batch

This commit is contained in:
kirilllzaitsev 2023-07-07 22:34:23 +02:00
parent 2b876bdd64
commit d480ff5be2
1 changed files with 39 additions and 2 deletions

View File

@ -39,6 +39,7 @@ for class_id, count in zip(*np.unique(PREDICTIONS[:, 5], return_counts=True)):
IDEAL_RESULT[class_id, class_id] = count
classes = np.arange(80)
num_classes = len(classes)
@pytest.mark.parametrize(
@ -77,8 +78,40 @@ def test_from_detections(
assert np.array_equal(result.matrix, expected_result)
def test_evaluate_detection_batch():
...
@pytest.mark.parametrize(
"predictions, targets, num_classes, conf_threshold, iou_threshold, expected_result, exception",
[
(
CERTAIN_DETECTIONS,
DETECTIONS,
num_classes,
0.3,
0.5,
IDEAL_RESULT,
DoesNotRaise(),
)
],
)
def test_evaluate_detection_batch(
predictions,
targets,
num_classes,
conf_threshold,
iou_threshold,
expected_result: Optional[np.ndarray],
exception: Exception,
):
with exception:
result = ConfusionMatrix._evaluate_detection_batch(
true_detections=targets,
pred_detections=predictions,
num_classes=num_classes,
conf_threshold=conf_threshold,
iou_threshold=iou_threshold,
)
assert result.diagonal().sum() == result.sum()
assert np.array_equal(result, expected_result)
def test_drop_extra_matches():
@ -87,3 +120,7 @@ def test_drop_extra_matches():
def test_benchmark():
...
def test_from_matrix():
...