Download examples/loader.py from windjj/datumwell-handwriting: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/windjj/datumwell-handwriting/resolve/main/examples/loader.py
- Command line
-
hf download hf://datasets/windjj/datumwell-handwriting/examples/loader.py
-
curl -L -o loader.py https://huggingface.co/datasets/windjj/datumwell-handwriting/resolve/main/examples/loader.py
1.01 kB
| """Lightweight local inspection; does not execute actions or download media.""" | |
| from pathlib import Path | |
| import json | |
| import pyarrow.parquet as pq | |
| def read_episode(root, episode=0): | |
| root=Path(root) | |
| info=json.loads((root/'meta/info.json').read_text()) | |
| if not 0<=episode<info['total_episodes']:raise IndexError(episode) | |
| return pq.read_table(root/f'data/chunk-000/file-{episode:03d}.parquet') | |
| def video_paths(root,episode=0): | |
| root=Path(root) | |
| info=json.loads((root/'meta/info.json').read_text()) | |
| return {key:root/f'videos/{key}/chunk-000/file-{episode:03d}.mp4' | |
| for key,value in info['features'].items() if value['dtype']=='video'} | |
| if __name__=='__main__': | |
| import argparse | |
| p=argparse.ArgumentParser();p.add_argument('root');p.add_argument('--episode',type=int,default=0);args=p.parse_args() | |
| table=read_episode(args.root,args.episode) | |
| print(table.slice(0,1).to_pylist()[0]) | |
| print({k:str(v) for k,v in video_paths(args.root,args.episode).items()}) | |