| |
| """Reconstruct MobileManipVLA_opensource from per-object tars. |
| |
| Repo layout: |
| MobileManiDataset/<robot>/<task>/<category>/<object>.tar |
| Each tar holds the ORIGINAL tree paths (<robot>/Final_0/<task>/<category>/<object>/...), |
| so extracting every tar into one output dir rebuilds the dataset exactly. |
| |
| Usage: |
| # after downloading the MobileManiDataset/ folder (e.g. via hf download) |
| python unpack.py --root ./MobileManiDataset --out ./MobileManipVLA_opensource [--verify] |
| """ |
| import argparse, glob, json, os, tarfile, hashlib |
|
|
|
|
| def sha256_file(path, buf=8 * 1024 * 1024): |
| h = hashlib.sha256() |
| with open(path, "rb") as f: |
| while True: |
| b = f.read(buf) |
| if not b: |
| break |
| h.update(b) |
| return h.hexdigest() |
|
|
|
|
| def main(): |
| ap = argparse.ArgumentParser() |
| ap.add_argument("--root", required=True, |
| help="dir containing MobileManiDataset/<robot>/... .tar files") |
| ap.add_argument("--out", required=True, help="output dir to extract into") |
| ap.add_argument("--verify", action="store_true", |
| help="verify each tar's sha256 against object_manifest.jsonl") |
| args = ap.parse_args() |
|
|
| tars = sorted(glob.glob(os.path.join(args.root, "**", "*.tar"), recursive=True)) |
| print(f"found {len(tars)} tars under {args.root}") |
|
|
| man = {} |
| mpath = os.path.join(args.root, "object_manifest.jsonl") |
| if os.path.exists(mpath): |
| for line in open(mpath): |
| line = line.strip() |
| if line: |
| r = json.loads(line) |
| man[os.path.basename(r["repo_path"])] = r |
|
|
| os.makedirs(args.out, exist_ok=True) |
| total_files = 0 |
| for i, t in enumerate(tars, 1): |
| base = os.path.basename(t) |
| if args.verify and base in man: |
| got = sha256_file(t) |
| exp = man[base]["sha256"] |
| ok = (got == exp) |
| print(f"[{i:3}/{len(tars)}] verify {base}: {'OK' if ok else 'MISMATCH'}") |
| if not ok: |
| raise SystemExit(f"sha256 mismatch for {base}: {got} != {exp}") |
| with tarfile.open(t, "r") as tar: |
| members = tar.getmembers() |
| tar.extractall(args.out) |
| total_files += sum(1 for m in members if m.isfile()) |
| print(f"[{i:3}/{len(tars)}] extracted {base}", flush=True) |
|
|
| print(f"\nDONE: extracted {len(tars)} tars, {total_files:,} files into {args.out}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|