Preserve validation manifests in failure sampling
This commit is contained in:
@@ -11,6 +11,17 @@ MODULE = importlib.util.module_from_spec(SPEC)
|
|||||||
SPEC.loader.exec_module(MODULE)
|
SPEC.loader.exec_module(MODULE)
|
||||||
|
|
||||||
|
|
||||||
|
def test_dataset_validation_source_preserves_manifest_path(tmp_path: Path):
|
||||||
|
source = tmp_path / "dataset.yaml"
|
||||||
|
source.write_text(
|
||||||
|
"path: /data/source\ntrain: /data/source/train.txt\n"
|
||||||
|
"val: /data/source/internal-val.txt\nnames:\n 0: building\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert MODULE.dataset_validation_source(source) == "/data/source/internal-val.txt"
|
||||||
|
|
||||||
|
|
||||||
def test_sampling_repeats_only_failed_region_train_tiles() -> None:
|
def test_sampling_repeats_only_failed_region_train_tiles() -> None:
|
||||||
manifest = {
|
manifest = {
|
||||||
"samples": [
|
"samples": [
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ def file_sha256(path: Path) -> str:
|
|||||||
return digest.hexdigest()
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def dataset_validation_source(source_yaml: Path) -> str:
|
||||||
|
"""Preserve the source dataset's validation contract verbatim."""
|
||||||
|
for raw_line in source_yaml.read_text(encoding="utf-8").splitlines():
|
||||||
|
key, separator, value = raw_line.partition(":")
|
||||||
|
if separator and key.strip() == "val" and value.strip():
|
||||||
|
return value.strip()
|
||||||
|
raise ValueError(f"Source dataset YAML has no validation source: {source_yaml}")
|
||||||
|
|
||||||
|
|
||||||
def build_sampling(
|
def build_sampling(
|
||||||
*,
|
*,
|
||||||
summary: dict[str, Any],
|
summary: dict[str, Any],
|
||||||
@@ -126,12 +135,12 @@ def main() -> int:
|
|||||||
train_list = args.output_dir / "train-failure-driven.txt"
|
train_list = args.output_dir / "train-failure-driven.txt"
|
||||||
train_list.write_text("\n".join(paths) + "\n", encoding="utf-8")
|
train_list.write_text("\n".join(paths) + "\n", encoding="utf-8")
|
||||||
source_yaml = args.summary.parent / "dataset.yaml"
|
source_yaml = args.summary.parent / "dataset.yaml"
|
||||||
val_dir = args.summary.parent / "images" / "val"
|
val_source = dataset_validation_source(source_yaml)
|
||||||
dataset_yaml = args.output_dir / "dataset.yaml"
|
dataset_yaml = args.output_dir / "dataset.yaml"
|
||||||
dataset_yaml.write_text(
|
dataset_yaml.write_text(
|
||||||
f"path: {args.output_dir}\n"
|
f"path: {args.output_dir}\n"
|
||||||
f"train: {train_list}\n"
|
f"train: {train_list}\n"
|
||||||
f"val: {val_dir}\n"
|
f"val: {val_source}\n"
|
||||||
"names:\n 0: building\n",
|
"names:\n 0: building\n",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user