Add learned building proposal filtering

This commit is contained in:
Jens
2026-07-27 07:35:50 +02:00
parent e5a642a7f7
commit 0acde4aba0
3 changed files with 281 additions and 0 deletions
@@ -0,0 +1,26 @@
from __future__ import annotations
import importlib.util
from pathlib import Path
SCRIPT = Path(__file__).parents[2] / "scripts" / "train_building_proposal_filter.py"
SPEC = importlib.util.spec_from_file_location("building_proposal_filter", SCRIPT)
assert SPEC and SPEC.loader
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)
def test_evenly_limited_is_deterministic() -> None:
assert MODULE.evenly_limited(list(range(10)), 3) == [0, 3, 6]
def test_validation_threshold_is_selected_without_test_data() -> None:
threshold, metrics = MODULE.choose_threshold([0.9, 0.8, 0.2, 0.1], [1, 1, 0, 0])
assert 0.2 < threshold <= 0.8
assert metrics["f1"] == 1.0
def test_negative_match_iou() -> None:
assert MODULE.iou((0, 0, 10, 10), (0, 0, 10, 10)) == 1.0
assert MODULE.iou((0, 0, 10, 10), (20, 20, 30, 30)) == 0.0