Datasets:
Download load_benchmark.py from benchmarkanon/EngIntervene: direct link, hf CLI and curl.
- Browser
- Download file 838 Bytes
-
https://huggingface.co/datasets/benchmarkanon/EngIntervene/resolve/main/load_benchmark.py
- Command line
-
hf download hf://datasets/benchmarkanon/EngIntervene/load_benchmark.py
-
curl -L -o load_benchmark.py https://huggingface.co/datasets/benchmarkanon/EngIntervene/resolve/main/load_benchmark.py
838 Bytes
| """Load the full anonymous benchmark locally; no network or credentials needed.""" | |
| from pathlib import Path | |
| def load_benchmark(root=None, decode_images=True): | |
| from datasets import load_dataset, Image, List | |
| root=Path(root) if root else Path(__file__).resolve().parent | |
| paths=sorted(str(path) for path in (root/'data').glob('test-*.parquet')) | |
| if not paths: | |
| raise FileNotFoundError('No benchmark Parquet shards in data/') | |
| ds=load_dataset('parquet',data_files={'test':paths},split='test') | |
| if not decode_images: | |
| ds=ds.cast_column('images',List(Image(decode=False))) | |
| return ds | |
| if __name__=='__main__': | |
| dataset=load_benchmark() | |
| assert len(dataset)==3229 | |
| example=dataset[0] | |
| print('Items:',len(dataset)) | |
| print('Example:',example['item_id'],example['task'],len(example['images'])) | |