junaid-simamdigital commited on
Commit
90672ec
·
verified ·
1 Parent(s): c7a3d73

Add held-out leakage guard

Browse files
tests/test_prepare_inference_manifest.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ from prepare_inference_manifest import prepare_inference_manifest
4
+
5
+
6
+ def test_preparer_excludes_held_out_views(tmp_path):
7
+ root = tmp_path / "inference_manifest_fixture"
8
+ (root / "images").mkdir(parents=True, exist_ok=True)
9
+ for name in ("train.ppm", "held.ppm"):
10
+ (root / "images" / name).write_text("P3\n1 1\n255\n255 0 0\n", encoding="ascii")
11
+ matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
12
+ pose = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
13
+ manifest = {"project": "Simam3D", "views": [
14
+ {"id": "train", "image": "images/train.ppm", "split": "train", "intrinsics": matrix, "extrinsics": pose},
15
+ {"id": "held", "image": "images/held.ppm", "split": "held_out", "intrinsics": matrix, "extrinsics": pose},
16
+ ]}
17
+ source = root / "capture.json"
18
+ destination = root / "inference.json"
19
+ source.write_text(json.dumps(manifest), encoding="utf-8")
20
+ prepared = prepare_inference_manifest(source, destination)
21
+ assert [view["id"] for view in prepared["views"]] == ["train"]
22
+ assert prepared["evaluation"]["excluded_held_out_view_ids"] == ["held"]
23
+ assert json.loads(destination.read_text(encoding="utf-8"))["views"][0]["id"] == "train"