Expand YOLO training AOIs safely
GeoIntel CI / docs-smoke (push) Has been cancelled
GeoIntel CI / contract-smoke (push) Has been cancelled

This commit is contained in:
Codex
2026-07-12 23:42:29 +02:00
parent 53cd38a5b2
commit 0f49c980ba
11 changed files with 310 additions and 7 deletions
@@ -1,6 +1,7 @@
from __future__ import annotations
import importlib.util
import math
from pathlib import Path
import sys
@@ -43,6 +44,40 @@ def test_operator_sample_registry_includes_kempen_reference_and_background_candi
assert all(module.SAMPLES[slug].sample_role == "background_candidate" for slug in expected_background_slugs)
def test_operator_training_expansion_preserves_geographically_separate_holdouts() -> None:
module = load_sample_preparer()
expected_expansion = {"olen_center", "lille_center", "oud_turnhout_center", "kasterlee_center"}
expected_holdouts = {"turnhout", "retie", "westerlo", "arendonk_heide"}
assert module.TRAINING_EXPANSION_SAMPLE_SLUGS == frozenset(expected_expansion)
assert module.DEFAULT_VALIDATION_SAMPLE_SLUGS == frozenset(expected_holdouts)
assert all(module.SAMPLES[slug].sample_role == "reference" for slug in expected_expansion)
assert all(not module.SAMPLES[slug].allow_empty_reference for slug in expected_expansion)
assert all(module.recommended_split_for_sample(module.SAMPLES[slug]) == "train" for slug in expected_expansion)
assert all(module.recommended_split_for_sample(module.SAMPLES[slug]) == "val" for slug in expected_holdouts)
def distance_m(left, right) -> float:
radius_m = 6_371_008.8
left_lat = math.radians(left.center_lat)
right_lat = math.radians(right.center_lat)
delta_lat = right_lat - left_lat
delta_lon = math.radians(right.center_lon - left.center_lon)
haversine = (
math.sin(delta_lat / 2) ** 2
+ math.cos(left_lat) * math.cos(right_lat) * math.sin(delta_lon / 2) ** 2
)
return 2 * radius_m * math.asin(math.sqrt(haversine))
reference_holdouts = expected_holdouts - {"arendonk_heide"}
for expansion_slug in expected_expansion:
expansion = module.SAMPLES[expansion_slug]
assert min(
distance_m(expansion, module.SAMPLES[holdout_slug])
for holdout_slug in reference_holdouts
) >= 2_000
def test_operator_background_candidates_are_unique_enough_for_hard_negative_training() -> None:
module = load_sample_preparer()