Harden operator tile background metadata
GeoIntel CI / docs-smoke (push) Has been cancelled
GeoIntel CI / contract-smoke (push) Has been cancelled

This commit is contained in:
Codex
2026-07-11 15:52:45 +02:00
parent 5d24242fb4
commit b3bd34c384
4 changed files with 97 additions and 2 deletions
+16 -1
View File
@@ -21,6 +21,9 @@ from typing import Any, Iterable
DEFAULT_MANIFEST_PATH = Path("/app/storage/operator-data/operator_samples_manifest.json")
DEFAULT_OUTPUT_DIR = Path("/app/storage/operator-data/yolo-building-tile-dataset")
REFERENCE_AOI_CATEGORY = "reference_aoi"
PURE_EMPTY_BACKGROUND_CATEGORY = "pure_empty_negative"
SPARSE_BACKGROUND_CATEGORY = "sparse_building_context"
rasterio: Any = None
Window: Any = None
Transformer: Any = None
@@ -165,6 +168,18 @@ def background_negative_repeat_count(
return max(1, background_negative_repeat)
def background_category_for_sample(sample: dict[str, Any]) -> str:
explicit_category = str(sample.get("background_category") or "").strip()
if explicit_category:
return explicit_category
if str(sample.get("sample_role") or "reference") != "background_candidate":
return REFERENCE_AOI_CATEGORY
reference_feature_count = int(sample.get("reference_feature_count") or 0)
if reference_feature_count <= 0:
return PURE_EMPTY_BACKGROUND_CATEGORY
return SPARSE_BACKGROUND_CATEGORY
def resolve_manifest_path(raw: str, manifest_path: Path) -> Path:
path = Path(raw)
if path.exists():
@@ -315,7 +330,7 @@ def export_sample_tiles(
) -> list[dict[str, Any]]:
sample_slug = str(sample["sample_slug"])
sample_role = str(sample.get("sample_role") or "reference")
background_category = str(sample.get("background_category") or "reference_aoi")
background_category = background_category_for_sample(sample)
split = "val" if sample_slug.lower() in val_slugs else "train"
raster_path = resolve_manifest_path(str(sample["raster_path"]), manifest_path)
reference_path = resolve_manifest_path(str(sample["reference_path"]), manifest_path)