Datasets:
Download code/make_release_archive.py from spatial-evidence-bench/SpatialEvidenceBench: direct link, hf CLI and curl.
- Browser
- Download file 4.41 kB
-
https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/81ec431b4e89dd554f2e9ee6ee04e3e137bca476/code/make_release_archive.py
- Command line
-
hf download hf://datasets/spatial-evidence-bench/SpatialEvidenceBench@81ec431b4e89dd554f2e9ee6ee04e3e137bca476/code/make_release_archive.py
-
curl -L -o make_release_archive.py https://huggingface.co/datasets/spatial-evidence-bench/SpatialEvidenceBench/resolve/81ec431b4e89dd554f2e9ee6ee04e3e137bca476/code/make_release_archive.py
4.41 kB
| import hashlib | |
| import json | |
| import shutil | |
| import subprocess | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| REL = ROOT / "release" / "data_v1" | |
| def sha256(path): | |
| h = hashlib.sha256() | |
| with open(path, "rb") as fh: | |
| for chunk in iter(lambda: fh.read(1 << 20), b""): | |
| h.update(chunk) | |
| return h.hexdigest() | |
| def main(): | |
| if REL.exists(): | |
| shutil.rmtree(REL) | |
| (REL / "metadata").mkdir(parents=True) | |
| (REL / "images").mkdir() | |
| (REL / "truth").mkdir() | |
| (REL / "prompts").mkdir() | |
| (REL / "specs").mkdir() | |
| (REL / "assets").mkdir() | |
| for name in ("truth_all.jsonl", "truth_dev.jsonl", "truth_test.jsonl"): | |
| shutil.copy(ROOT / "dataset" / name, REL / "truth" / name) | |
| shutil.copy(ROOT / "dataset" / "prompts_all.jsonl", REL / "prompts" / "prompts_all.jsonl") | |
| for name in ("scene_specs_dev.jsonl", "scene_specs_test.jsonl"): | |
| shutil.copy(ROOT / "dataset" / name, REL / "specs" / name) | |
| for name in ("asset_catalog.jsonl", "licenses.csv"): | |
| shutil.copy(ROOT / "assets" / name, REL / "assets" / name) | |
| for name in ("croissant.json", "dataset_card.md"): | |
| shutil.copy(ROOT / "release" / name, REL / "metadata" / name) | |
| (REL / "code").mkdir() | |
| for src in sorted((ROOT / "scripts").glob("*.py")): | |
| shutil.copy(src, REL / "code" / src.name) | |
| for src in sorted((ROOT / "analysis").glob("*.py")): | |
| shutil.copy(src, REL / "code" / src.name) | |
| shutil.copy(ROOT / "release" / "reproduce.sh", REL / "code" / "reproduce.sh") | |
| # 逐条件预测:只收最终三模型的合成域与自然域文件 | |
| pred = REL / "predictions" | |
| pred.mkdir() | |
| models = ("qwen3vl", "qwen25vl", "deepseekvl2s") | |
| for model in models: | |
| src_dir = ROOT / "predictions" / f"synth_{model}" | |
| dst_dir = pred / f"synth_{model}" | |
| dst_dir.mkdir() | |
| for src in sorted(src_dir.glob("*.jsonl")): | |
| shutil.copy(src, dst_dir / src.name) | |
| nat_src = ROOT / "predictions" / "natural" | |
| nat_dst = pred / "natural" | |
| nat_dst.mkdir() | |
| for src in sorted(nat_src.glob("*.jsonl")): | |
| if any(model in src.name for model in models): | |
| shutil.copy(src, nat_dst / src.name) | |
| # 分析结果:论文里每个数字都能由这些 JSON 重算 | |
| results = REL / "results" | |
| results.mkdir() | |
| for model in models: | |
| for name in (f"synth_{model}.json", f"matrix_{model}.json", f"boot_{model}.json"): | |
| shutil.copy(ROOT / "analysis" / name, results / name) | |
| for name in ("paired_effects.json",): | |
| shutil.copy(ROOT / "analysis" / name, results / name) | |
| for src in sorted((ROOT / "analysis").glob("natural_*.json")): | |
| shutil.copy(src, results / src.name) | |
| subprocess.run(["cp", "-al", str(ROOT / "dataset" / "render_all"), str(REL / "images" / "render_all")], check=True) | |
| mismatched = [] | |
| frames = [] | |
| with open(ROOT / "dataset" / "truth_all.jsonl") as fh: | |
| for line in fh: | |
| row = json.loads(line) | |
| frames.append(row["image"]) | |
| if row.get("computed") != row.get("declared"): | |
| mismatched.append(row) | |
| with open(REL / "metadata" / "truth_mismatch.json", "w") as fh: | |
| json.dump({"n_mismatch": len(mismatched), "records": mismatched}, fh, indent=2, ensure_ascii=False) | |
| split = {"seed": 20261106, "n_scenes": 2400, "n_images": len(frames), | |
| "dev_prefix_limit": 150, "note": "scene index below 150 per family is dev"} | |
| with open(REL / "metadata" / "split_manifest.json", "w") as fh: | |
| json.dump(split, fh, indent=2) | |
| sums = [] | |
| for path in sorted(REL.rglob("*")): | |
| if path.is_file() and path.name != "CHECKSUMS.sha256": | |
| sums.append(f"{sha256(path)} {path.relative_to(REL)}") | |
| (REL / "metadata" / "CHECKSUMS.sha256").write_text("\n".join(sums) + "\n") | |
| print(json.dumps({"files": len(sums), "mismatch": len(mismatched)})) | |
| def checksums_only(): | |
| sums = [] | |
| for path in sorted(REL.rglob("*")): | |
| if path.is_file() and path.name != "CHECKSUMS.sha256": | |
| sums.append(f"{sha256(path)} {path.relative_to(REL)}") | |
| (REL / "metadata" / "CHECKSUMS.sha256").write_text("\n".join(sums) + "\n") | |
| print(json.dumps({"rehashed": len(sums)})) | |
| if __name__ == "__main__": | |
| import sys | |
| if "--checksums-only" in sys.argv: | |
| checksums_only() | |
| else: | |
| main() | |