Spaces:
Sleeping
Sleeping
File size: 700 Bytes
78d2329 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import json
from pathlib import Path
import torch
from tqdm import tqdm
DATASET_PATH = Path("/capstor/store/cscs/swissai/a03/hxu/datasets/dl3dv_2kres")
if __name__ == "__main__":
# "train" or "test"
for stage in ["test"]:
stage = DATASET_PATH / stage
index = {}
for chunk_path in tqdm(
sorted(list(stage.iterdir())), desc=f"Indexing {stage.name}"
):
if chunk_path.suffix == ".torch":
chunk = torch.load(chunk_path)
for example in chunk:
index[example["key"]] = str(chunk_path.relative_to(stage))
with (stage / "index.json").open("w") as f:
json.dump(index, f)
|