"""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)