preprocessing/make_manifest.py
1.9 KB · 47 lines · python Raw
1 """Write the encoder manifest (episodes.jsonl) for one task from the downloaded raw/ tree.
2
3 python preprocessing/make_manifest.py --raw-root $ACTS_DATA_ROOT/raw --task rope --out OUT/episodes_rope.jsonl
4
5 raw/ layout (WitneyWW/vtm-cosmos-data):
6 raw/videos/<episode>/{view_middle,tactile_left,tactile_right,wrist_left,wrist_right}.mp4 (30 fps)
7 raw/parquet/<episode>.parquet per-native-frame sensor poses + calibrated normal force
8 raw/episodes.json [{episode, tree, num_frames}] for the 166 split episodes
9 Row schema = what third_party/wan22_vae/encode_tactile_wan22.py reads."""
10 from __future__ import annotations
11
12 import argparse
13 import json
14 from pathlib import Path
15
16 TREES = {"umi_all": "mixed_mb", "rope": "mixed_rope", "pusht": "mixed_pushT"}
17 STREAMS = ["view_middle", "tactile_left", "tactile_right", "wrist_left", "wrist_right"]
18
19
20 def main():
21 ap = argparse.ArgumentParser()
22 ap.add_argument("--raw-root", type=Path, required=True)
23 ap.add_argument("--task", required=True, choices=sorted(TREES))
24 ap.add_argument("--out", type=Path, required=True)
25 ap.add_argument("--episodes", nargs="*", default=None, help="subset (episode stems)")
26 a = ap.parse_args()
27 rows = [r for r in json.loads((a.raw_root / "episodes.json").read_text()) if r["tree"] == TREES[a.task]]
28 if a.episodes:
29 rows = [r for r in rows if r["episode"] in set(a.episodes)]
30 out = []
31 for r in rows:
32 d = a.raw_root / "videos" / r["episode"]
33 row = {"episode": r["episode"], "num_frames": int(r["num_frames"]), "task": a.task}
34 for s in STREAMS:
35 p = d / f"{s}.mp4"
36 if not p.is_file():
37 raise FileNotFoundError(p)
38 row[s] = str(p.resolve())
39 out.append(row)
40 a.out.parent.mkdir(parents=True, exist_ok=True)
41 a.out.write_text("".join(json.dumps(r) + "\n" for r in out))
42 print(f"{len(out)} episodes -> {a.out}")
43
44
45 if __name__ == "__main__":
46 main()
47