Expand YOLO training AOIs safely
This commit is contained in:
@@ -201,3 +201,62 @@ def test_false_negative_audit_finds_persistent_reference_misses(tmp_path: Path)
|
||||
assert active["false_negative_area_m2"]["median"] > 0
|
||||
assert report["recommendations"]
|
||||
assert (output_dir / "detection_false_negative_audit.md").is_file()
|
||||
|
||||
|
||||
def test_false_negative_audit_rejects_mismatched_reference_populations(tmp_path: Path) -> None:
|
||||
script = ROOT / "scripts" / "audit_detection_false_negative_evidence.py"
|
||||
portfolio_args = []
|
||||
for label, source_ids in (("active", ("one", "two")), ("candidate", ("one",))):
|
||||
portfolio_dir = tmp_path / label
|
||||
evidence_dir = portfolio_dir / "samples" / "geel" / "evidence"
|
||||
evidence_dir.mkdir(parents=True)
|
||||
evidence_path = evidence_dir / "calibration_evidence.geojson"
|
||||
evidence_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
_evidence_feature(
|
||||
"false_negative",
|
||||
source_id,
|
||||
_polygon(5.0 + index * 0.001, 51.2, 0.0001),
|
||||
)
|
||||
for index, source_id in enumerate(source_ids)
|
||||
],
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
portfolio_path = portfolio_dir / "calibration_evidence_portfolio.json"
|
||||
portfolio_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"model_asset_id": f"model-{label}",
|
||||
"samples": [
|
||||
{
|
||||
"sample_slug": "geel",
|
||||
"evidence_geojson_path": str(evidence_path),
|
||||
}
|
||||
],
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
portfolio_args.extend(("--portfolio", f"{label}={portfolio_path}"))
|
||||
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(script),
|
||||
*portfolio_args,
|
||||
"--output-dir",
|
||||
str(tmp_path / "audit"),
|
||||
],
|
||||
cwd=ROOT,
|
||||
check=False,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
assert result.returncode != 0
|
||||
assert "different reference populations" in result.stderr
|
||||
|
||||
Reference in New Issue
Block a user