GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT = Path(__file__).parents[2] / "scripts" / "evaluate_belgium_building_candidate.py"
|
|
SPEC = importlib.util.spec_from_file_location("candidate_evaluation", SCRIPT)
|
|
assert SPEC and SPEC.loader
|
|
MODULE = importlib.util.module_from_spec(SPEC)
|
|
SPEC.loader.exec_module(MODULE)
|
|
|
|
|
|
def test_iou_and_one_to_one_matching() -> None:
|
|
reference = [(0.0, 0.0, 10.0, 10.0)]
|
|
predictions = [((0.0, 0.0, 10.0, 10.0), 0.9), ((0.0, 0.0, 10.0, 10.0), 0.8)]
|
|
assert MODULE.iou(reference[0], reference[0]) == 1.0
|
|
assert MODULE.match_boxes(predictions, reference, confidence=0.25, match_iou=0.5) == (1, 1, 0)
|
|
|
|
|
|
def test_empty_reference_counts_false_positives() -> None:
|
|
predictions = [((0.0, 0.0, 10.0, 10.0), 0.4)]
|
|
assert MODULE.match_boxes(predictions, [], confidence=0.25, match_iou=0.5) == (0, 1, 0)
|
|
assert MODULE.match_boxes(predictions, [], confidence=0.5, match_iou=0.5) == (0, 0, 0)
|
|
|
|
|
|
def test_box_scaling_preserves_center() -> None:
|
|
assert MODULE.scale_box((10.0, 20.0, 30.0, 40.0), 1.5) == (5.0, 15.0, 35.0, 45.0)
|
|
|
|
|
|
def test_containment_suppression_removes_nested_lower_score_box() -> None:
|
|
predictions = [
|
|
((0.0, 0.0, 20.0, 20.0), 0.9),
|
|
((5.0, 5.0, 15.0, 15.0), 0.8),
|
|
((25.0, 0.0, 35.0, 10.0), 0.7),
|
|
]
|
|
assert MODULE.suppress_contained_predictions(predictions, 0.8) == [
|
|
predictions[0],
|
|
predictions[2],
|
|
]
|