Download scripts/verify_dataset.py from Benxelua/Detector: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/Benxelua/Detector/resolve/main/scripts/verify_dataset.py
- Command line
-
hf download hf://Benxelua/Detector/scripts/verify_dataset.py
-
curl -L -o verify_dataset.py https://huggingface.co/Benxelua/Detector/resolve/main/scripts/verify_dataset.py
1.72 kB
| #!/usr/bin/env python3 | |
| """Fail-fast verification for the immutable paired bright/dark LOD protocol.""" | |
| from __future__ import annotations | |
| import argparse, json | |
| from pathlib import Path | |
| import sys | |
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | |
| from detector_lib import EXPECTED, LockedLODDataset | |
| def main(): | |
| p=argparse.ArgumentParser(); p.add_argument("--dataset-root",type=Path,required=True); p.add_argument("--labels-root",type=Path,default=Path(__file__).resolve().parents[1]/"labels"); p.add_argument("--package-root",type=Path,default=Path(__file__).resolve().parents[1]); a=p.parse_args() | |
| report={"dataset_root":str(a.dataset_root),"splits":{},"status":"passed"} | |
| ids={} | |
| for domain in ("bright","dark"): | |
| for split, expected in EXPECTED.items(): | |
| manifest=a.package_root/"manifests"/f"{domain}_{split}.json"; ds=LockedLODDataset(manifest,a.dataset_root,a.labels_root) | |
| if len(ds)!=expected: raise RuntimeError((domain,split,len(ds),expected)) | |
| # Resolve one exemplar and validate labels/class IDs without copying data. | |
| _, target=ds[0] | |
| report["splits"][f"{domain}_{split}"]={"count":len(ds),"first_labels":target["labels"].tolist()} | |
| ids.setdefault(split,{})[domain]=[x["pair_id"] for x in ds.items] | |
| for split, pair in ids.items(): | |
| if pair["bright"] != pair["dark"]: raise RuntimeError(f"bright/dark pairing mismatch for {split}") | |
| train=set(ids["train"]["bright"]); val=set(ids["val"]["bright"]); test=set(ids["test"]["bright"]) | |
| if train & val or train & test or val & test: raise RuntimeError("locked split overlap") | |
| print(json.dumps(report,indent=2)) | |
| if __name__=="__main__": main() | |