Datasets:
Tasks:
Image-to-3D
Modalities:
Geospatial
Languages:
English
Size:
100K<n<1M
Tags:
3d-point-cloud
point-cloud-generation
city-scale
remote-sensing
satellite-imagery
digital-surface-model
License:
| #!/usr/bin/env python3 | |
| """ | |
| Generate the exact train / val / test split used by City3D-MultiGen. | |
| This replicates the deterministic split from the training dataloader: | |
| all_files = sorted(list(Path(data_root).glob('**/grid_*.las'))) | |
| n_train = int(n_total * train_split) | |
| n_val = int(n_total * val_split) | |
| train = all_files[:n_train] | |
| val = all_files[n_train:n_train + n_val] | |
| test = all_files[n_train + n_val:] | |
| There is **no shuffling and no random seed** — the split is a sequential slice of | |
| the path-sorted tile list. Running this on the same assembled `output/` directory | |
| therefore reproduces exactly the split used to produce the paper's results. | |
| Because tile filenames (`grid_<id>`) are ordered along the spatial grid, this | |
| path-sorted sequential split yields spatially contiguous train/val/test regions. | |
| Usage: | |
| python scripts/make_splits.py \ | |
| --data_root /path/to/output \ | |
| --train_split 0.8 --val_split 0.1 \ | |
| --out_dir metadata/splits | |
| """ | |
| import argparse | |
| from pathlib import Path | |
| def main(): | |
| ap = argparse.ArgumentParser(description="Reproduce the City3D-MultiGen tile split.") | |
| ap.add_argument("--data_root", required=True, | |
| help="Directory containing the assembled tiles (grid_*/grid_*.las).") | |
| ap.add_argument("--train_split", type=float, default=0.8) | |
| ap.add_argument("--val_split", type=float, default=0.1) | |
| ap.add_argument("--out_dir", default="metadata/splits") | |
| args = ap.parse_args() | |
| # Identical to the training dataloader: recursive glob, sorted by path. | |
| all_files = sorted(list(Path(args.data_root).glob("**/grid_*.las"))) | |
| n = len(all_files) | |
| if n == 0: | |
| raise SystemExit(f"No grid_*.las files found under {args.data_root}") | |
| n_train = int(n * args.train_split) | |
| n_val = int(n * args.val_split) | |
| splits = { | |
| "train": all_files[:n_train], | |
| "val": all_files[n_train:n_train + n_val], | |
| "test": all_files[n_train + n_val:], | |
| } | |
| out = Path(args.out_dir) | |
| out.mkdir(parents=True, exist_ok=True) | |
| for name, files in splits.items(): | |
| ids = [f.stem for f in files] # e.g. "grid_120256" | |
| (out / f"{name}.txt").write_text("\n".join(ids) + "\n") | |
| print(f"{name:5s}: {len(ids):6d} tiles -> {out / (name + '.txt')}") | |
| print(f"total: {n} tiles " | |
| f"(train={n_train}, val={n_val}, test={n - n_train - n_val})") | |
| if __name__ == "__main__": | |
| main() | |