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
@@ -116,6 +116,7 @@ def audit_feature_collection(payload: dict[str, Any], geod: Any, shape: Any) ->
raise SystemExit("Evidence GeoJSON must be a FeatureCollection")
features = payload.get("features") or []
false_negative_ids: set[str] = set()
reference_ids: set[str] = set()
false_negative_areas: list[float] = []
matched_reference_areas: list[float] = []
bucket_counts = {
@@ -141,11 +142,13 @@ def audit_feature_collection(payload: dict[str, Any], geod: Any, shape: Any) ->
)
area_m2 = abs(float(geod.geometry_area_perimeter(geometry)[0]))
bucket = area_bucket(area_m2)
reference_id = stable_reference_id(feature, geometry)
reference_ids.add(reference_id)
bucket_role = "false_negative" if role == "false_negative" else "matched_reference"
bucket_counts[bucket][bucket_role] += 1
bucket_counts[bucket]["total_reference"] += 1
if role == "false_negative":
false_negative_ids.add(stable_reference_id(feature, geometry))
false_negative_ids.add(reference_id)
false_negative_areas.append(area_m2)
else:
matched_reference_areas.append(area_m2)
@@ -157,6 +160,7 @@ def audit_feature_collection(payload: dict[str, Any], geod: Any, shape: Any) ->
total_reference = len(false_negative_areas) + len(matched_reference_areas)
return {
"false_negative_ids": false_negative_ids,
"reference_ids": reference_ids,
"false_negative_count": len(false_negative_areas),
"matched_reference_count": len(matched_reference_areas),
"total_reference_count": total_reference,
@@ -284,16 +288,31 @@ def run_audit(portfolio_args: list[str], output_dir: Path) -> tuple[Path, Path]:
for sample_slug in sorted(expected_slugs):
portfolio_rows = []
false_negative_sets = []
reference_sets = []
for label, _ in parsed_portfolios:
raw = portfolio_samples[label][sample_slug]
false_negative_sets.append(raw["false_negative_ids"])
reference_sets.append(raw["reference_ids"])
portfolio_rows.append(
{key: value for key, value in raw.items() if key != "false_negative_ids"}
{
key: value
for key, value in raw.items()
if key not in {"false_negative_ids", "reference_ids"}
}
)
if any(reference_ids != reference_sets[0] for reference_ids in reference_sets[1:]):
counts = ", ".join(
f"{label}={len(reference_ids)}"
for (label, _), reference_ids in zip(parsed_portfolios, reference_sets, strict=True)
)
raise SystemExit(
f"Sample {sample_slug} has different reference populations across portfolios ({counts})"
)
persistent_ids = sorted(set.intersection(*false_negative_sets))
sample_reports.append(
{
"sample_slug": sample_slug,
"reference_population_count": len(reference_sets[0]),
"persistent_false_negative_count": len(persistent_ids),
"persistent_reference_ids": persistent_ids,
"portfolios": portfolio_rows,