parquet
Browse files
MPCC.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import base64
|
| 3 |
-
import io
|
| 4 |
-
from PIL import Image
|
| 5 |
-
import datasets
|
| 6 |
-
|
| 7 |
-
_DESCRIPTION = """MPCC: A benchmark for Multimodal Planning under Complex Constraints. This dataset includes Calendar Planning, Flight Planning, and Meeting Planning, each with three difficulty levels: easy, medium, hard."""
|
| 8 |
-
|
| 9 |
-
_TASKS = {
|
| 10 |
-
"calendar_planning": "Calendar Planning",
|
| 11 |
-
"flight_planning": "Flight Planning",
|
| 12 |
-
"meeting_planning": "Meeting Planning"
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
_LEVELS = ["easy", "medium", "hard"]
|
| 16 |
-
|
| 17 |
-
class MPCCConfig(datasets.BuilderConfig):
|
| 18 |
-
def __init__(self, task_key, **kwargs):
|
| 19 |
-
super().__init__(**kwargs)
|
| 20 |
-
self.task_key = task_key
|
| 21 |
-
|
| 22 |
-
class MPCC(datasets.GeneratorBasedBuilder):
|
| 23 |
-
BUILDER_CONFIGS = [
|
| 24 |
-
MPCCConfig(
|
| 25 |
-
name=task_key,
|
| 26 |
-
task_key=task_key,
|
| 27 |
-
version=datasets.Version("1.0.0"),
|
| 28 |
-
description=f"{task_name} subset of MPCC"
|
| 29 |
-
)
|
| 30 |
-
for task_key, task_name in _TASKS.items()
|
| 31 |
-
]
|
| 32 |
-
|
| 33 |
-
def _info(self):
|
| 34 |
-
return datasets.DatasetInfo(
|
| 35 |
-
description=_DESCRIPTION,
|
| 36 |
-
features=datasets.Features({
|
| 37 |
-
"image": datasets.Image(),
|
| 38 |
-
"text": datasets.Value("string")
|
| 39 |
-
}),
|
| 40 |
-
supervised_keys=None,
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
def _split_generators(self, dl_manager):
|
| 44 |
-
task_dir = _TASKS[self.config.task_key]
|
| 45 |
-
base_name = self.config.task_key.replace("_planning", "")
|
| 46 |
-
file_template = {
|
| 47 |
-
"easy": f"{base_name}_plan_easy.tsv",
|
| 48 |
-
"medium": f"{base_name}_plan_medium.tsv",
|
| 49 |
-
"hard": f"{base_name}_plan_hard.tsv"
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
return [
|
| 53 |
-
datasets.SplitGenerator(
|
| 54 |
-
name=level,
|
| 55 |
-
gen_kwargs={
|
| 56 |
-
"filepath": os.path.join(task_dir, fname)
|
| 57 |
-
}
|
| 58 |
-
)
|
| 59 |
-
for level, fname in file_template.items()
|
| 60 |
-
]
|
| 61 |
-
|
| 62 |
-
def _generate_examples(self, filepath):
|
| 63 |
-
with open(filepath, encoding="utf-8") as f:
|
| 64 |
-
header = f.readline().strip().split("\t")
|
| 65 |
-
for idx, line in enumerate(f):
|
| 66 |
-
fields = line.strip().split("\t")
|
| 67 |
-
row = dict(zip(header, fields))
|
| 68 |
-
image = Image.open(io.BytesIO(base64.b64decode(row["image_base64"]))).convert("RGB")
|
| 69 |
-
yield idx, {
|
| 70 |
-
"image": image,
|
| 71 |
-
"text": row["text"]
|
| 72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|