Download portable_loader.py from AetherLabs-AI/RobotAgentBench-TrainingData: direct link, hf CLI and curl.
- Browser
- Download file 2.71 kB
-
https://huggingface.co/datasets/AetherLabs-AI/RobotAgentBench-TrainingData/resolve/main/portable_loader.py
- Command line
-
hf download hf://datasets/AetherLabs-AI/RobotAgentBench-TrainingData/portable_loader.py
-
curl -L -o portable_loader.py https://huggingface.co/datasets/AetherLabs-AI/RobotAgentBench-TrainingData/resolve/main/portable_loader.py
2.71 kB
| #!/usr/bin/env python3 | |
| """Load every unified action22/state23 episode using unmodified official LeRobot.""" | |
| import argparse | |
| import json | |
| import os | |
| from pathlib import Path | |
| def collection_root(root, name="all"): | |
| # Historical CLI alias selects the same full set; it never creates a subset. | |
| if name == "main": | |
| name = "all" | |
| root = Path(root).resolve() | |
| registry = json.loads((root / "meta/collections.json").read_text()) | |
| if registry.get("default_collection") != "all" or [r["name"] for r in registry["collections"]] != ["all"]: | |
| raise ValueError("This loader requires the single unified all collection") | |
| row = next((r for r in registry["collections"] if r["name"] == name), None) | |
| if row is None: | |
| raise ValueError(f"Unknown collection {name}; available: {[r['name'] for r in registry['collections']]}") | |
| rel = Path(row["root"]) | |
| if rel.is_absolute() or ".." in rel.parts: | |
| raise ValueError("Collection root must stay inside the extracted dataset") | |
| target = (root / rel).resolve() | |
| if not target.is_relative_to(root): | |
| raise ValueError("Collection root escapes dataset") | |
| return target | |
| def load_collection(root, name="all", episodes=None, cache_dir=None): | |
| os.environ["HF_HUB_OFFLINE"] = "1" | |
| os.environ["HF_DATASETS_OFFLINE"] = "1" | |
| os.environ["TOKENIZERS_PARALLELISM"] = "false" | |
| if cache_dir is not None: | |
| os.environ["HF_DATASETS_CACHE"] = str(Path(cache_dir).resolve()) | |
| from lerobot.datasets.lerobot_dataset import LeRobotDataset | |
| return LeRobotDataset( | |
| repo_id=f"local/robotagentbench-{name}", root=collection_root(root, name), episodes=episodes, | |
| download_videos=False, video_backend="pyav", tolerance_s=0.0003, | |
| ) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--root", type=Path, required=True, help="Extracted dataset directory containing meta/collections.json") | |
| parser.add_argument("--collection", default="all") | |
| parser.add_argument("--episode", type=int, default=0) | |
| parser.add_argument("--frame", type=int, default=0) | |
| parser.add_argument("--cache-dir", type=Path) | |
| args = parser.parse_args() | |
| dataset = load_collection(args.root, args.collection, [args.episode], args.cache_dir) | |
| sample = dataset[args.frame] | |
| print(json.dumps({"root": str(collection_root(args.root, args.collection)), "collection": args.collection, | |
| "selected_episode": args.episode, "selected_episode_frames": len(dataset), | |
| "task": sample.get("task"), | |
| "sample_shapes": {k: list(v.shape) for k, v in sample.items() if hasattr(v, "shape")}}, indent=2)) | |