Promote focused small-building detector
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-13 12:15:27 +02:00
parent b3f7c3ca63
commit 1689dce928
20 changed files with 546 additions and 61 deletions
@@ -51,7 +51,7 @@ def test_operator_training_expansion_preserves_geographically_separate_holdouts(
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 expected_holdouts.issubset(module.DEFAULT_VALIDATION_SAMPLE_SLUGS)
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)
@@ -78,6 +78,51 @@ def test_operator_training_expansion_preserves_geographically_separate_holdouts(
) >= 2_000
def test_small_building_expansion_has_separate_training_and_validation_centers() -> None:
module = load_sample_preparer()
expected_training = {
"beerse_center",
"rijkevorsel_center",
"hoogstraten_center",
"vorselaar_center",
}
expected_validation = {"vosselaar_center", "grobbendonk_center"}
assert module.SMALL_BUILDING_TRAINING_SAMPLE_SLUGS == frozenset(expected_training)
assert module.SMALL_BUILDING_VALIDATION_SAMPLE_SLUGS == frozenset(expected_validation)
assert expected_validation.issubset(module.DEFAULT_VALIDATION_SAMPLE_SLUGS)
assert all(module.SAMPLES[slug].sample_role == "reference" for slug in expected_training | expected_validation)
assert all(
module.recommended_split_for_sample(module.SAMPLES[slug]) == "train"
for slug in expected_training
)
assert all(
module.recommended_split_for_sample(module.SAMPLES[slug]) == "val"
for slug in expected_validation
)
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))
protected_holdouts = expected_validation | {"turnhout", "retie", "westerlo"}
for training_slug in expected_training:
training_sample = module.SAMPLES[training_slug]
assert min(
distance_m(training_sample, module.SAMPLES[holdout_slug])
for holdout_slug in protected_holdouts
) >= 2_000
def test_operator_background_candidates_are_unique_enough_for_hard_negative_training() -> None:
module = load_sample_preparer()