Download eval/source/robot_tools/droid/scripts/fetch_episode.py from JiayiWuLeo/RobotZero: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/JiayiWuLeo/RobotZero/resolve/main/eval/source/robot_tools/droid/scripts/fetch_episode.py
- Command line
-
hf download hf://datasets/JiayiWuLeo/RobotZero/eval/source/robot_tools/droid/scripts/fetch_episode.py
-
curl -L -o fetch_episode.py https://huggingface.co/datasets/JiayiWuLeo/RobotZero/resolve/main/eval/source/robot_tools/droid/scripts/fetch_episode.py
1.5 kB
| """Download one raw episode (metadata, trajectory.h5, all MP4s) from GCS. | |
| Usage: python fetch_episode.py <uuid> <relative_path> | |
| """ | |
| import json | |
| import sys | |
| import urllib.parse | |
| import urllib.request | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| BASE = "https://storage.googleapis.com/gresearch/robotics/droid_raw/1.0.1" | |
| def get(url, dst, tries=3): | |
| dst = Path(dst) | |
| if dst.exists() and dst.stat().st_size > 0: | |
| return | |
| for i in range(tries): | |
| try: | |
| urllib.request.urlretrieve(url, dst) | |
| return | |
| except Exception: | |
| if i == tries - 1: | |
| raise | |
| def main(uid, rel): | |
| d = ROOT / "data" / uid | |
| (d / "recordings/MP4").mkdir(parents=True, exist_ok=True) | |
| pref = urllib.parse.quote(f"robotics/droid_raw/1.0.1/{rel}/recordings/MP4/", safe="") | |
| listing = json.load(urllib.request.urlopen( | |
| f"https://storage.googleapis.com/storage/v1/b/gresearch/o?prefix={pref}", timeout=20)) | |
| for it in listing.get("items", []): | |
| fn = it["name"].split("/")[-1] | |
| if "stereo" in fn.lower(): | |
| continue | |
| get(f"{BASE}/{urllib.parse.quote(rel)}/recordings/MP4/{fn}", d / "recordings/MP4" / fn) | |
| get(f"{BASE}/{urllib.parse.quote(rel)}/metadata_{urllib.parse.quote(uid)}.json", d / "metadata.json") | |
| get(f"{BASE}/{urllib.parse.quote(rel)}/trajectory.h5", d / "trajectory.h5") | |
| print("fetched", uid) | |
| if __name__ == "__main__": | |
| main(sys.argv[1], sys.argv[2]) | |