Datasets:
Download scripts/load_dataset.py from thomeboi/MAGAR-Bench: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/datasets/thomeboi/MAGAR-Bench/resolve/main/scripts/load_dataset.py
- Command line
-
hf download hf://datasets/thomeboi/MAGAR-Bench/scripts/load_dataset.py
-
curl -L -o load_dataset.py https://huggingface.co/datasets/thomeboi/MAGAR-Bench/resolve/main/scripts/load_dataset.py
753 Bytes
| """Load MAGAR-Bench and resolve repository-relative image paths. | |
| Run this file from the root of a cloned Hugging Face dataset repository. | |
| """ | |
| from pathlib import Path | |
| from datasets import load_dataset | |
| def load_magar_bench(repo_root: str | Path = "."): | |
| root = Path(repo_root) | |
| dataset = load_dataset( | |
| "json", | |
| data_files={ | |
| "train": str(root / "data" / "train.jsonl"), | |
| "test_inputs": str(root / "data" / "test_inputs.jsonl"), | |
| }, | |
| ) | |
| def resolve_images(record): | |
| record["images"] = [str(root / image_path) for image_path in record["images"]] | |
| return record | |
| return dataset.map(resolve_images) | |
| if __name__ == "__main__": | |
| loaded = load_magar_bench() | |
| print(loaded) | |