Download dataloader.py from NJU-LINK/EmbodiedExploreBench: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/datasets/NJU-LINK/EmbodiedExploreBench/resolve/main/dataloader.py
- Command line
-
hf download hf://datasets/NJU-LINK/EmbodiedExploreBench/dataloader.py
-
curl -L -o dataloader.py https://huggingface.co/datasets/NJU-LINK/EmbodiedExploreBench/resolve/main/dataloader.py
2.08 kB
| """Inspect the manifest or load a complete benchmark task document.""" | |
| import argparse | |
| from collections import Counter | |
| import csv | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| def load_manifest(root=ROOT, scene=None, task_type=None): | |
| root = Path(root).resolve() | |
| with (root / 'data/manifest.tsv').open(encoding='utf-8') as stream: | |
| rows = list(csv.DictReader(stream, delimiter='\t')) | |
| if scene: | |
| rows = [row for row in rows if row['scene'] == scene] | |
| if task_type: | |
| task_type = task_type.replace('-', '_') | |
| rows = [row for row in rows if row['skill'].replace('-', '_') == task_type] | |
| return rows | |
| def task_path(row, root=ROOT): | |
| directory = Path(root).resolve() / 'data' | |
| path = (directory / row['task_file']).resolve() | |
| if path.parent != directory or path.suffix != '.json': | |
| raise ValueError(f"Invalid task path: {row['task_file']}") | |
| return path | |
| def load_task(task_id, root=ROOT): | |
| """Return the full document, including internal environment/evaluator fields.""" | |
| for row in load_manifest(root): | |
| if Path(row['task_file']).stem == task_id: | |
| return json.loads(task_path(row, root).read_text(encoding='utf-8')) | |
| raise KeyError(f'Unknown task ID: {task_id}') | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--root', type=Path, default=ROOT) | |
| parser.add_argument('--scene') | |
| parser.add_argument('--task-type') | |
| parser.add_argument('--task-id', help='Print one complete task document.') | |
| args = parser.parse_args() | |
| if args.task_id: | |
| print(json.dumps(load_task(args.task_id, args.root), ensure_ascii=False, indent=2)) | |
| return | |
| rows = load_manifest(args.root, args.scene, args.task_type) | |
| print(json.dumps({ | |
| 'tasks': len(rows), | |
| 'scenes': dict(sorted(Counter(row['scene'] for row in rows).items())), | |
| 'task_types': dict(sorted(Counter(row['skill'].replace('-', '_') for row in rows).items())), | |
| }, indent=2)) | |
| if __name__ == '__main__': | |
| main() | |