Datasets:
Download inject_map.py from luuuulinnnn/Nurec_eval: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/datasets/luuuulinnnn/Nurec_eval/resolve/main/inject_map.py
- Command line
-
hf download hf://datasets/luuuulinnnn/Nurec_eval/inject_map.py
-
curl -L -o inject_map.py https://huggingface.co/datasets/luuuulinnnn/Nurec_eval/resolve/main/inject_map.py
1.47 kB
| """Add clipgt/map_data parquet files to NRE-exported USDZs. | |
| Usage: | |
| python inject_map.py <src_usdz> <map_dir> <dst_usdz> | |
| map_dir is the per-scene directory under | |
| /mnt/data4/nurec_ood64/map/ood_closeloop_map/<uuid>/. | |
| """ | |
| from __future__ import annotations | |
| import shutil | |
| import sys | |
| import zipfile | |
| from pathlib import Path | |
| MAP_FILES = [ | |
| "cf_crosswalks.parquet", | |
| "cf_lane_topology_node.parquet", | |
| "cf_road_boundary.parquet", | |
| "dw_lane.parquet", | |
| "lane_chunk.parquet", | |
| "lane_rail.parquet", | |
| ] | |
| def inject(src: Path, map_dir: Path, dst: Path) -> None: | |
| shutil.copy2(src, dst) | |
| with zipfile.ZipFile(dst, "a", compression=zipfile.ZIP_STORED) as zf: | |
| existing = set(zf.namelist()) | |
| for name in MAP_FILES: | |
| arc = f"map_data/{name}" | |
| if arc in existing: | |
| print(f" skip (already present): {arc}") | |
| continue | |
| src_file = map_dir / name | |
| if not src_file.exists(): | |
| raise FileNotFoundError(src_file) | |
| zf.write(src_file, arcname=arc) | |
| print(f" added: {arc} ({src_file.stat().st_size} bytes)") | |
| def main() -> int: | |
| if len(sys.argv) != 4: | |
| print(__doc__) | |
| return 1 | |
| src, map_dir, dst = map(Path, sys.argv[1:]) | |
| print(f"inject {map_dir} -> {src} => {dst}") | |
| inject(src, map_dir, dst) | |
| print(f"wrote {dst} ({dst.stat().st_size} bytes)") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |