Datasets:
Tasks:
Visual Question Answering
Formats:
parquet
Sub-tasks:
visual-question-answering
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Commit
•
1e853eb
1
Parent(s):
00b0e4a
Convert dataset to Parquet (#5)
Browse files- Convert dataset to Parquet (ce6b283add5660041bdec82d37ebc55c91af9025)
- Add compguesswhat-zero_shot data files (2e4aa4c52a868a558bee4bb0dadf6e8f7d9213bb)
- Delete loading script (b4a856ff9d26bcd14f51f4e84bbcc1e759d55858)
- Delete loading script auxiliary file (d80f88a46da2c2b877427dc88df535fec22670d1)
- README.md +33 -14
- compguesswhat-original/test-00000-of-00001.parquet +3 -0
- compguesswhat-original/train-00000-of-00001.parquet +3 -0
- compguesswhat-original/validation-00000-of-00001.parquet +3 -0
- compguesswhat-zero_shot/nd_test-00000-of-00001.parquet +3 -0
- compguesswhat-zero_shot/nd_valid-00000-of-00001.parquet +3 -0
- compguesswhat-zero_shot/od_test-00000-of-00001.parquet +3 -0
- compguesswhat-zero_shot/od_valid-00000-of-00001.parquet +3 -0
- compguesswhat.py +0 -254
- create_dummy_data.py +0 -96
README.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
---
|
2 |
annotations_creators:
|
3 |
- machine-generated
|
4 |
-
language:
|
5 |
-
- en
|
6 |
language_creators:
|
7 |
- found
|
|
|
|
|
8 |
license:
|
9 |
- unknown
|
10 |
multilinguality:
|
11 |
- monolingual
|
12 |
-
pretty_name: CompGuessWhat?!
|
13 |
size_categories:
|
14 |
- 100K<n<1M
|
15 |
source_datasets:
|
@@ -19,6 +18,7 @@ task_categories:
|
|
19 |
task_ids:
|
20 |
- visual-question-answering
|
21 |
paperswithcode_id: compguesswhat
|
|
|
22 |
dataset_info:
|
23 |
- config_name: compguesswhat-original
|
24 |
features:
|
@@ -84,16 +84,16 @@ dataset_info:
|
|
84 |
sequence: float32
|
85 |
splits:
|
86 |
- name: train
|
87 |
-
num_bytes:
|
88 |
num_examples: 46341
|
89 |
- name: validation
|
90 |
-
num_bytes:
|
91 |
num_examples: 9738
|
92 |
- name: test
|
93 |
-
num_bytes:
|
94 |
num_examples: 9621
|
95 |
-
download_size:
|
96 |
-
dataset_size:
|
97 |
- config_name: compguesswhat-zero_shot
|
98 |
features:
|
99 |
- name: id
|
@@ -159,19 +159,38 @@ dataset_info:
|
|
159 |
dtype: string
|
160 |
splits:
|
161 |
- name: nd_valid
|
162 |
-
num_bytes:
|
163 |
num_examples: 5343
|
164 |
- name: nd_test
|
165 |
-
num_bytes:
|
166 |
num_examples: 13836
|
167 |
- name: od_valid
|
168 |
-
num_bytes:
|
169 |
num_examples: 5372
|
170 |
- name: od_test
|
171 |
-
num_bytes:
|
172 |
num_examples: 13300
|
173 |
-
download_size:
|
174 |
-
dataset_size:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
---
|
176 |
|
177 |
# Dataset Card for "compguesswhat"
|
|
|
1 |
---
|
2 |
annotations_creators:
|
3 |
- machine-generated
|
|
|
|
|
4 |
language_creators:
|
5 |
- found
|
6 |
+
language:
|
7 |
+
- en
|
8 |
license:
|
9 |
- unknown
|
10 |
multilinguality:
|
11 |
- monolingual
|
|
|
12 |
size_categories:
|
13 |
- 100K<n<1M
|
14 |
source_datasets:
|
|
|
18 |
task_ids:
|
19 |
- visual-question-answering
|
20 |
paperswithcode_id: compguesswhat
|
21 |
+
pretty_name: CompGuessWhat?!
|
22 |
dataset_info:
|
23 |
- config_name: compguesswhat-original
|
24 |
features:
|
|
|
84 |
sequence: float32
|
85 |
splits:
|
86 |
- name: train
|
87 |
+
num_bytes: 123556580
|
88 |
num_examples: 46341
|
89 |
- name: validation
|
90 |
+
num_bytes: 25441428
|
91 |
num_examples: 9738
|
92 |
- name: test
|
93 |
+
num_bytes: 25369227
|
94 |
num_examples: 9621
|
95 |
+
download_size: 105349759
|
96 |
+
dataset_size: 174367235
|
97 |
- config_name: compguesswhat-zero_shot
|
98 |
features:
|
99 |
- name: id
|
|
|
159 |
dtype: string
|
160 |
splits:
|
161 |
- name: nd_valid
|
162 |
+
num_bytes: 13510589
|
163 |
num_examples: 5343
|
164 |
- name: nd_test
|
165 |
+
num_bytes: 36228021
|
166 |
num_examples: 13836
|
167 |
- name: od_valid
|
168 |
+
num_bytes: 14051972
|
169 |
num_examples: 5372
|
170 |
- name: od_test
|
171 |
+
num_bytes: 32950869
|
172 |
num_examples: 13300
|
173 |
+
download_size: 6548812
|
174 |
+
dataset_size: 96741451
|
175 |
+
configs:
|
176 |
+
- config_name: compguesswhat-original
|
177 |
+
data_files:
|
178 |
+
- split: train
|
179 |
+
path: compguesswhat-original/train-*
|
180 |
+
- split: validation
|
181 |
+
path: compguesswhat-original/validation-*
|
182 |
+
- split: test
|
183 |
+
path: compguesswhat-original/test-*
|
184 |
+
- config_name: compguesswhat-zero_shot
|
185 |
+
data_files:
|
186 |
+
- split: nd_valid
|
187 |
+
path: compguesswhat-zero_shot/nd_valid-*
|
188 |
+
- split: nd_test
|
189 |
+
path: compguesswhat-zero_shot/nd_test-*
|
190 |
+
- split: od_valid
|
191 |
+
path: compguesswhat-zero_shot/od_valid-*
|
192 |
+
- split: od_test
|
193 |
+
path: compguesswhat-zero_shot/od_test-*
|
194 |
---
|
195 |
|
196 |
# Dataset Card for "compguesswhat"
|
compguesswhat-original/test-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16b2a80dd58e66aad5fe8857c95a812e2206ae05a55ec6cfa89d38518577415a
|
3 |
+
size 15268653
|
compguesswhat-original/train-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a4099d3ab1826c0acbf47710ffa8197cf52204cfaa6df44149c1d60ee01dd41f
|
3 |
+
size 74763809
|
compguesswhat-original/validation-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:024d592321b0bc7f7f8d6419b1f45f8e188875f4bf187a59037c694b6e806784
|
3 |
+
size 15317297
|
compguesswhat-zero_shot/nd_test-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c7bfb006600e91cf151b644b1495c5688268997cd024c9ce832d7500302d690e
|
3 |
+
size 2434268
|
compguesswhat-zero_shot/nd_valid-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:03d7d02f63bac35c043d2e73f1cceec10d365440f165348ff86dc8cf3fc9fcd4
|
3 |
+
size 929562
|
compguesswhat-zero_shot/od_test-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:67eee5a8432934369fa4d4eb33e7fd11e4b57fb85bd2d5e826e46905b7d1a54b
|
3 |
+
size 2255581
|
compguesswhat-zero_shot/od_valid-00000-of-00001.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e6b4ef094118fb380e70a83dbcc2fa1c43cc56f655f48d419b8bfbd72bf795ac
|
3 |
+
size 929401
|
compguesswhat.py
DELETED
@@ -1,254 +0,0 @@
|
|
1 |
-
import gzip
|
2 |
-
import json
|
3 |
-
import os
|
4 |
-
|
5 |
-
import datasets
|
6 |
-
|
7 |
-
|
8 |
-
class CompguesswhatConfig(datasets.BuilderConfig):
|
9 |
-
"""BuilderConfig for CompGuessWhat?!"""
|
10 |
-
|
11 |
-
def __init__(self, data_url, splits, gameplay_scenario, **kwargs):
|
12 |
-
"""
|
13 |
-
|
14 |
-
Args:
|
15 |
-
gameplay_scenario: to specify if we want to load original CompGuessWhat?! split ('original') or
|
16 |
-
the zero-shot reference games based on NOCAPS images ('zero_shot')
|
17 |
-
**kwargs: keyword arguments forwarded to super.
|
18 |
-
"""
|
19 |
-
super(CompguesswhatConfig, self).__init__(
|
20 |
-
version=datasets.Version("0.2.0", "Second CompGuessWhat?! release"), **kwargs
|
21 |
-
)
|
22 |
-
assert gameplay_scenario in (
|
23 |
-
"original",
|
24 |
-
"zero_shot",
|
25 |
-
), "Invalid choice for parameter 'gameplay_scenario': {gameplay_scenario}. Valid values are ('original', 'zero_shot')."
|
26 |
-
|
27 |
-
self.gameplay_scenario = gameplay_scenario
|
28 |
-
self.splits = splits
|
29 |
-
self.data_url = data_url
|
30 |
-
|
31 |
-
|
32 |
-
class Compguesswhat(datasets.GeneratorBasedBuilder):
|
33 |
-
_CITATION = """\
|
34 |
-
@inproceedings{suglia2020compguesswhat,
|
35 |
-
title={CompGuessWhat?!: a Multi-task Evaluation Framework for Grounded Language Learning},
|
36 |
-
author={Suglia, Alessandro, Konstas, Ioannis, Vanzo, Andrea, Bastianelli, Emanuele, Desmond Elliott, Stella Frank and Oliver Lemon},
|
37 |
-
booktitle={Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
|
38 |
-
year={2020}
|
39 |
-
}
|
40 |
-
"""
|
41 |
-
|
42 |
-
_DESCRIPTION = """
|
43 |
-
CompGuessWhat?! is an instance of a multi-task framework for evaluating the quality of learned neural representations,
|
44 |
-
in particular concerning attribute grounding. Use this dataset if you want to use the set of games whose reference
|
45 |
-
scene is an image in VisualGenome. Visit the website for more details: https://compguesswhat.github.io
|
46 |
-
"""
|
47 |
-
|
48 |
-
BUILDER_CONFIGS = [
|
49 |
-
CompguesswhatConfig(
|
50 |
-
name="compguesswhat-original",
|
51 |
-
gameplay_scenario="original",
|
52 |
-
description="CompGuessWhat?! subset of games from the original GuessWhat?! dataset",
|
53 |
-
data_url="https://www.dropbox.com/s/qd9wlydpkpmq8rr/compguesswhat-original.zip?dl=1",
|
54 |
-
splits={
|
55 |
-
"train": "compguesswhat.train.jsonl.gz",
|
56 |
-
"valid": "compguesswhat.valid.jsonl.gz",
|
57 |
-
"test": "compguesswhat.test.jsonl.gz",
|
58 |
-
},
|
59 |
-
),
|
60 |
-
CompguesswhatConfig(
|
61 |
-
name="compguesswhat-zero_shot",
|
62 |
-
gameplay_scenario="zero_shot",
|
63 |
-
description="CompGuessWhat?! reference set of games for zero-shot evaluation using NOCAPS images",
|
64 |
-
data_url="https://www.dropbox.com/s/f5o2t7aiok7kpcm/compguesswhat-zero_shot.zip?dl=1",
|
65 |
-
splits={
|
66 |
-
"nd_valid": "compguesswhat.nd_valid.jsonl.gz",
|
67 |
-
"nd_test": "compguesswhat.nd_test.jsonl.gz",
|
68 |
-
"od_valid": "compguesswhat.od_valid.jsonl.gz",
|
69 |
-
"od_test": "compguesswhat.od_test.jsonl.gz",
|
70 |
-
},
|
71 |
-
),
|
72 |
-
]
|
73 |
-
|
74 |
-
VERSION = datasets.Version("0.2.0")
|
75 |
-
|
76 |
-
def _info(self):
|
77 |
-
if self.config.gameplay_scenario == "original":
|
78 |
-
return datasets.DatasetInfo(
|
79 |
-
# This is the description that will appear on the datasets page.
|
80 |
-
description=self._DESCRIPTION,
|
81 |
-
# datasets.features.FeatureConnectors
|
82 |
-
features=datasets.Features(
|
83 |
-
{
|
84 |
-
"id": datasets.Value("int32"),
|
85 |
-
"target_id": datasets.Value("int32"),
|
86 |
-
"timestamp": datasets.Value("string"),
|
87 |
-
"status": datasets.Value("string"),
|
88 |
-
"image": {
|
89 |
-
# this is the image ID in GuessWhat?! which corresponds to the MSCOCO id
|
90 |
-
"id": datasets.Value("int32"),
|
91 |
-
"file_name": datasets.Value("string"),
|
92 |
-
"flickr_url": datasets.Value("string"),
|
93 |
-
"coco_url": datasets.Value("string"),
|
94 |
-
"height": datasets.Value("int32"),
|
95 |
-
"width": datasets.Value("int32"),
|
96 |
-
# this field represents the corresponding image metadata that can be found in VisualGenome
|
97 |
-
# in the file image_data.json
|
98 |
-
# We copy it over so that we avoid any confusion or possible wrong URL
|
99 |
-
# Please use the original image files to resolve photos
|
100 |
-
"visual_genome": {
|
101 |
-
"width": datasets.Value("int32"),
|
102 |
-
"height": datasets.Value("int32"),
|
103 |
-
"url": datasets.Value("string"),
|
104 |
-
"coco_id": datasets.Value("int32"),
|
105 |
-
# this is the actual VisualGenome image ID
|
106 |
-
# because we can't rely store it as an integer we same it as string
|
107 |
-
"flickr_id": datasets.Value("string"),
|
108 |
-
"image_id": datasets.Value("string"),
|
109 |
-
},
|
110 |
-
},
|
111 |
-
"qas": datasets.features.Sequence(
|
112 |
-
{
|
113 |
-
"question": datasets.Value("string"),
|
114 |
-
"answer": datasets.Value("string"),
|
115 |
-
"id": datasets.Value("int32"),
|
116 |
-
}
|
117 |
-
),
|
118 |
-
"objects": datasets.features.Sequence(
|
119 |
-
{
|
120 |
-
"id": datasets.Value("int32"),
|
121 |
-
"bbox": datasets.Sequence(datasets.Value("float32"), length=4),
|
122 |
-
"category": datasets.Value("string"),
|
123 |
-
"area": datasets.Value("float32"),
|
124 |
-
"category_id": datasets.Value("int32"),
|
125 |
-
"segment": datasets.features.Sequence(
|
126 |
-
datasets.features.Sequence(datasets.Value("float32"))
|
127 |
-
),
|
128 |
-
}
|
129 |
-
),
|
130 |
-
}
|
131 |
-
),
|
132 |
-
# If there's a common (input, target) tuple from the features,
|
133 |
-
# specify them here. They'll be used if as_supervised=True in
|
134 |
-
# builder.as_dataset.
|
135 |
-
supervised_keys=None,
|
136 |
-
# Homepage of the dataset for documentation
|
137 |
-
homepage="https://compguesswhat.github.io/",
|
138 |
-
citation=self._CITATION,
|
139 |
-
)
|
140 |
-
elif self.config.gameplay_scenario == "zero_shot":
|
141 |
-
return datasets.DatasetInfo(
|
142 |
-
# This is the description that will appear on the datasets page.
|
143 |
-
description=self._DESCRIPTION,
|
144 |
-
# datasets.features.FeatureConnectors
|
145 |
-
features=datasets.Features(
|
146 |
-
{
|
147 |
-
"id": datasets.Value("int32"),
|
148 |
-
"target_id": datasets.Value("string"),
|
149 |
-
"status": datasets.Value("string"),
|
150 |
-
"image": {
|
151 |
-
"id": datasets.Value("int32"),
|
152 |
-
"file_name": datasets.Value("string"),
|
153 |
-
"coco_url": datasets.Value("string"),
|
154 |
-
"height": datasets.Value("int32"),
|
155 |
-
"width": datasets.Value("int32"),
|
156 |
-
"license": datasets.Value("int32"),
|
157 |
-
"open_images_id": datasets.Value("string"),
|
158 |
-
"date_captured": datasets.Value("string"),
|
159 |
-
},
|
160 |
-
"objects": datasets.features.Sequence(
|
161 |
-
{
|
162 |
-
"id": datasets.Value("string"),
|
163 |
-
"bbox": datasets.Sequence(datasets.Value("float32"), length=4),
|
164 |
-
"category": datasets.Value("string"),
|
165 |
-
"area": datasets.Value("float32"),
|
166 |
-
"category_id": datasets.Value("int32"),
|
167 |
-
"IsOccluded": datasets.Value("int32"),
|
168 |
-
"IsTruncated": datasets.Value("int32"),
|
169 |
-
"segment": datasets.features.Sequence(
|
170 |
-
{
|
171 |
-
"MaskPath": datasets.Value("string"),
|
172 |
-
"LabelName": datasets.Value("string"),
|
173 |
-
"BoxID": datasets.Value("string"),
|
174 |
-
"BoxXMin": datasets.Value("string"),
|
175 |
-
"BoxXMax": datasets.Value("string"),
|
176 |
-
"BoxYMin": datasets.Value("string"),
|
177 |
-
"BoxYMax": datasets.Value("string"),
|
178 |
-
"PredictedIoU": datasets.Value("string"),
|
179 |
-
"Clicks": datasets.Value("string"),
|
180 |
-
}
|
181 |
-
),
|
182 |
-
}
|
183 |
-
),
|
184 |
-
}
|
185 |
-
),
|
186 |
-
# If there's a common (input, target) tuple from the features,
|
187 |
-
# specify them here. They'll be used if as_supervised=True in
|
188 |
-
# builder.as_dataset.
|
189 |
-
supervised_keys=None,
|
190 |
-
# Homepage of the dataset for documentation
|
191 |
-
homepage="https://compguesswhat.github.io/",
|
192 |
-
citation=self._CITATION,
|
193 |
-
)
|
194 |
-
|
195 |
-
def _split_generators(self, dl_manager):
|
196 |
-
"""Returns SplitGenerators."""
|
197 |
-
dl_dir = dl_manager.download_and_extract(self.config.data_url)
|
198 |
-
|
199 |
-
splits_gen = []
|
200 |
-
|
201 |
-
for split_id, split_filename in self.config.splits.items():
|
202 |
-
if self.config.gameplay_scenario == "original":
|
203 |
-
if "train" in split_id:
|
204 |
-
split_name = datasets.Split.TRAIN
|
205 |
-
elif "valid" in split_id:
|
206 |
-
split_name = datasets.Split.VALIDATION
|
207 |
-
elif "test" in split_id:
|
208 |
-
split_name = datasets.Split.TEST
|
209 |
-
else:
|
210 |
-
split_name = datasets.Split(split_id)
|
211 |
-
|
212 |
-
full_split_name = "-".join(["compguesswhat", self.config.gameplay_scenario])
|
213 |
-
splits_gen.append(
|
214 |
-
datasets.SplitGenerator(
|
215 |
-
name=split_name,
|
216 |
-
gen_kwargs={
|
217 |
-
"filepath": os.path.join(
|
218 |
-
dl_dir,
|
219 |
-
full_split_name,
|
220 |
-
self.VERSION.version_str,
|
221 |
-
split_filename,
|
222 |
-
)
|
223 |
-
},
|
224 |
-
)
|
225 |
-
)
|
226 |
-
|
227 |
-
return splits_gen
|
228 |
-
|
229 |
-
def _generate_examples(self, filepath):
|
230 |
-
def _extract_game_tuple(data):
|
231 |
-
data = data.decode("utf-8")
|
232 |
-
game = json.loads(data.strip("\n"))
|
233 |
-
|
234 |
-
# we refactor the data structure a bit to fit with the new version
|
235 |
-
game["target_id"] = game["object_id"]
|
236 |
-
if "object_id" in game:
|
237 |
-
del game["object_id"]
|
238 |
-
|
239 |
-
if "questioner_id" in game:
|
240 |
-
del game["questioner_id"]
|
241 |
-
###
|
242 |
-
|
243 |
-
if "visual_genome" in game["image"]:
|
244 |
-
# We need to cast it to string so that we avoid issues with int size
|
245 |
-
game["image"]["visual_genome"]["image_id"] = str(game["image"]["visual_genome"]["image_id"])
|
246 |
-
game["image"]["visual_genome"]["flickr_id"] = str(game["image"]["visual_genome"]["flickr_id"])
|
247 |
-
|
248 |
-
return game["id"], game
|
249 |
-
|
250 |
-
"""Yields examples."""
|
251 |
-
with open(filepath, "rb") as gzip_file:
|
252 |
-
with gzip.open(gzip_file) as in_file:
|
253 |
-
for data in in_file:
|
254 |
-
yield _extract_game_tuple(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create_dummy_data.py
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
import gzip
|
2 |
-
import json
|
3 |
-
import logging
|
4 |
-
import os
|
5 |
-
from argparse import ArgumentParser
|
6 |
-
|
7 |
-
|
8 |
-
parser = ArgumentParser()
|
9 |
-
parser.add_argument(
|
10 |
-
"-d",
|
11 |
-
"--data_path",
|
12 |
-
type=str,
|
13 |
-
required=True,
|
14 |
-
help="Data path containing the CompGuessWhat?! datasets (files with 'jsonl.gz' extension)",
|
15 |
-
)
|
16 |
-
parser.add_argument(
|
17 |
-
"--examples",
|
18 |
-
type=int,
|
19 |
-
default=5,
|
20 |
-
help="Number of games to consider in the dummy dataset",
|
21 |
-
)
|
22 |
-
original_data_files = {
|
23 |
-
"train": "compguesswhat.train.jsonl.gz",
|
24 |
-
"valid": "compguesswhat.valid.jsonl.gz",
|
25 |
-
"test": "compguesswhat.test.jsonl.gz",
|
26 |
-
}
|
27 |
-
|
28 |
-
zs_data_files = {
|
29 |
-
"nd_valid": "compguesswhat.nd_valid.jsonl.gz",
|
30 |
-
"od_valid": "compguesswhat.od_valid.jsonl.gz",
|
31 |
-
"nd_test": "compguesswhat.nd_test.jsonl.gz",
|
32 |
-
"od_test": "compguesswhat.od_test.jsonl.gz",
|
33 |
-
}
|
34 |
-
|
35 |
-
COMPGUESSWHAT_ROOT = "datasets/compguesswhat/"
|
36 |
-
|
37 |
-
|
38 |
-
def create_dummy_data_for_split(data_path, dataset_name, dataset_version, data_files):
|
39 |
-
full_dataset_name = "-".join(["compguesswhat", dataset_name])
|
40 |
-
dummy_data_path = os.path.join(
|
41 |
-
COMPGUESSWHAT_ROOT,
|
42 |
-
"dummy",
|
43 |
-
full_dataset_name,
|
44 |
-
dataset_version,
|
45 |
-
"dummy_data",
|
46 |
-
full_dataset_name,
|
47 |
-
dataset_version,
|
48 |
-
)
|
49 |
-
|
50 |
-
if not os.path.exists(dummy_data_path):
|
51 |
-
os.makedirs(dummy_data_path)
|
52 |
-
|
53 |
-
for split_name, split_file in data_files.items():
|
54 |
-
logging.info(f"Generating dummy data for split {split_name} (num. examples = {args.examples})")
|
55 |
-
|
56 |
-
split_filepath = os.path.join(data_path, full_dataset_name, dataset_version, split_file)
|
57 |
-
logging.info(f"Reading split file {split_filepath}")
|
58 |
-
with gzip.open(split_filepath) as in_file:
|
59 |
-
dummy_filepath = os.path.join(dummy_data_path, split_file)
|
60 |
-
with gzip.open(dummy_filepath, mode="w") as out_file:
|
61 |
-
for i, line in enumerate(in_file):
|
62 |
-
if i > args.examples:
|
63 |
-
break
|
64 |
-
|
65 |
-
data = json.loads(line.strip())
|
66 |
-
out_file.write(json.dumps(data).encode("utf-8"))
|
67 |
-
out_file.write(b"\n")
|
68 |
-
|
69 |
-
|
70 |
-
def main(args):
|
71 |
-
# args.data_path is the directory containing the already downloaded dataset files
|
72 |
-
# we assume that the dataset test was successful and we have the file dataset_info.json
|
73 |
-
dataset_info_path = os.path.join(COMPGUESSWHAT_ROOT, "dataset_infos.json")
|
74 |
-
|
75 |
-
if not os.path.exists(dataset_info_path):
|
76 |
-
raise ValueError(
|
77 |
-
"The file 'dataset_info.json' doesn't exists. Make sure that you run the dataset tests via datasets-cli."
|
78 |
-
)
|
79 |
-
|
80 |
-
with open(dataset_info_path, encoding="utf-8") as in_file:
|
81 |
-
dataset_info = json.load(in_file)
|
82 |
-
|
83 |
-
dataset_version = dataset_info["compguesswhat-original"]["version"]["version_str"]
|
84 |
-
|
85 |
-
logging.info(f"Creating dummy data for CompGuessWhat?! {dataset_version}")
|
86 |
-
|
87 |
-
logging.info("Original dataset...")
|
88 |
-
create_dummy_data_for_split(args.data_path, "original", dataset_version, original_data_files)
|
89 |
-
|
90 |
-
logging.info("Zero-shot dataset...")
|
91 |
-
create_dummy_data_for_split(args.data_path, "zero_shot", dataset_version, zs_data_files)
|
92 |
-
|
93 |
-
|
94 |
-
if __name__ == "__main__":
|
95 |
-
args = parser.parse_args()
|
96 |
-
main(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|