Download scripts/load_batch.py from Crobotia/iUMI: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/Crobotia/iUMI/resolve/main/scripts/load_batch.py
- Command line
-
hf download hf://datasets/Crobotia/iUMI/scripts/load_batch.py
-
curl -L -o load_batch.py https://huggingface.co/datasets/Crobotia/iUMI/resolve/main/scripts/load_batch.py
1.75 kB
| """Iterate local single-episode LeRobot datasets using episodes.csv.""" | |
| import argparse | |
| import csv | |
| from pathlib import Path | |
| from lerobot.datasets.lerobot_dataset import LeRobotDataset | |
| def iter_datasets(root, names=None, limit=4): | |
| root = Path(root).resolve() | |
| selected = set(names) if names else None | |
| loaded = 0 | |
| with (root / "episodes.csv").open(newline="") as stream: | |
| for row in csv.DictReader(stream): | |
| name = row["episode"] | |
| if selected is not None and name not in selected: | |
| continue | |
| path = root / row["episode_path"] | |
| if not (path / "meta/info.json").is_file(): | |
| raise FileNotFoundError(f"Extract the corresponding shard first: {name}") | |
| dataset = LeRobotDataset(repo_id=f"Crobotia/{name}", root=path, | |
| video_backend="pyav") | |
| yield name, dataset | |
| loaded += 1 | |
| if limit is not None and loaded >= limit: | |
| return | |
| if loaded == 0: | |
| raise ValueError("No selected episode was found in episodes.csv") | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--root", type=Path, default=Path(".")) | |
| parser.add_argument("--episodes", nargs="+", help="Episode names from episodes.csv") | |
| parser.add_argument("--limit", type=int, default=4, help="Maximum episodes to load (default: 4)") | |
| args = parser.parse_args() | |
| if args.limit < 1: | |
| parser.error("--limit must be positive") | |
| for name, dataset in iter_datasets(args.root, args.episodes, args.limit): | |
| sample = dataset[0] | |
| print(name, dataset.num_frames, sample["task"], tuple(sample["observation.state"].shape)) | |