Download scripts/release_reader.py from luyingxi35/RoboFAPE: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/luyingxi35/RoboFAPE/resolve/main/scripts/release_reader.py
- Command line
-
hf download hf://datasets/luyingxi35/RoboFAPE/scripts/release_reader.py
-
curl -L -o release_reader.py https://huggingface.co/datasets/luyingxi35/RoboFAPE/resolve/main/scripts/release_reader.py
1.04 kB
| """Read the portable release without the original collection directories.""" | |
| from pathlib import Path | |
| import numpy as np | |
| from datasets import load_dataset, load_from_disk | |
| CACHES={'train':'local_RoboFAPE_train','test_ind':'setting_12_ind_test','test_ood':'setting_4_ood_test'} | |
| def resolve(root,relative): | |
| root=Path(root).resolve() | |
| if Path(relative).is_absolute():raise ValueError('Expected a release-relative path') | |
| path=(root/relative).resolve() | |
| if not path.is_relative_to(root):raise ValueError('Path escapes the release directory') | |
| return path | |
| def load_processed(root,split): | |
| return load_from_disk(str(Path(root)/'repro/processed'/CACHES[split]/'processed_dataset')) | |
| def read_frames(root,row): | |
| with np.load(resolve(Path(root)/'repro/processed',row['frames']),allow_pickle=False) as data: | |
| return data['frames'] | |
| def load_native(root,cache_dir=None): | |
| return load_dataset('parquet',data_files={s:sorted(str(p) for p in (Path(root)/'data'/s).glob('*.parquet')) for s in CACHES},cache_dir=cache_dir) | |