CalfKing commited on
Commit
d3202fb
1 Parent(s): 4f5bd69

Update vtqa2023.py

Browse files
Files changed (1) hide show
  1. vtqa2023.py +33 -20
vtqa2023.py CHANGED
@@ -24,10 +24,12 @@ datasets.Image()
24
  """ VTQA Dataset"""
25
 
26
  _CITATION = """\
27
- @inproceedings{Chen2023VTQA,
28
- title={VTQA: Visual Text Question Answering via Entity Alignment and Cross-Media Reasoning},
29
- author={Kang Chen and Xiangqian Wu},
30
- year={2023}
 
 
31
  }
32
  """
33
 
@@ -89,7 +91,9 @@ _DATA_URL = "data"
89
  class VTQAConfig(datasets.BuilderConfig):
90
  """BuilderConfig for VTQA."""
91
 
92
- def __init__(self, data_url: str = None, use_cws=False, local_url=None, **kwargs):
 
 
93
  super(VTQAConfig, self).__init__(
94
  version=datasets.Version("1.0.0", ""),
95
  description=self.description,
@@ -98,6 +102,7 @@ class VTQAConfig(datasets.BuilderConfig):
98
  self.data_url = _DATA_URL if data_url is None else data_url
99
  self.use_cws = use_cws
100
  self.local_url = local_url
 
101
 
102
  @property
103
  def features(self):
@@ -186,7 +191,7 @@ class VTQA(datasets.GeneratorBasedBuilder):
186
  cws_supp_dir = _get_url("cws_supp")
187
  self.cws_supp_dir = cws_supp_dir
188
 
189
- return [
190
  datasets.SplitGenerator(
191
  name=datasets.Split.TRAIN,
192
  gen_kwargs={
@@ -229,22 +234,30 @@ class VTQA(datasets.GeneratorBasedBuilder):
229
  "labeled": False,
230
  },
231
  ),
232
- datasets.SplitGenerator(
233
- name=datasets.Split.TEST,
234
- gen_kwargs={
235
- "filepath": os.path.join(annotation_dir, "test.json"),
236
- "image_dir": (
237
- os.path.join(image_dir, "test") if image_dir else None
238
- ),
239
- "region_dir": (
240
- os.path.join(region_dir, "test") if region_dir else None
241
- ),
242
- "grid_dir": os.path.join(grid_dir, "test") if grid_dir else None,
243
- "labeled": False,
244
- },
245
- ),
246
  ]
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  def _generate_examples(
249
  self, filepath, image_dir=None, region_dir=None, grid_dir=None, labeled=True
250
  ):
 
24
  """ VTQA Dataset"""
25
 
26
  _CITATION = """\
27
+ @inproceedings{chen2024vtqa,
28
+ title={VTQA: Visual Text Question Answering via Entity Alignment and Cross-Media Reasoning},
29
+ author={Chen, Kang and Wu, Xiangqian},
30
+ booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
31
+ pages={27218--27227},
32
+ year={2024}
33
  }
34
  """
35
 
 
91
  class VTQAConfig(datasets.BuilderConfig):
92
  """BuilderConfig for VTQA."""
93
 
94
+ def __init__(
95
+ self, data_url: str = None, use_cws=False, local_url=None, get_test_split=False, **kwargs
96
+ ):
97
  super(VTQAConfig, self).__init__(
98
  version=datasets.Version("1.0.0", ""),
99
  description=self.description,
 
102
  self.data_url = _DATA_URL if data_url is None else data_url
103
  self.use_cws = use_cws
104
  self.local_url = local_url
105
+ self.get_test_split = get_test_split
106
 
107
  @property
108
  def features(self):
 
191
  cws_supp_dir = _get_url("cws_supp")
192
  self.cws_supp_dir = cws_supp_dir
193
 
194
+ datasets_split = [
195
  datasets.SplitGenerator(
196
  name=datasets.Split.TRAIN,
197
  gen_kwargs={
 
234
  "labeled": False,
235
  },
236
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  ]
238
 
239
+ if self.config.get_test_split:
240
+ return datasets_split + [
241
+ datasets.SplitGenerator(
242
+ name=datasets.Split.TEST,
243
+ gen_kwargs={
244
+ "filepath": os.path.join(annotation_dir, "test.json"),
245
+ "image_dir": (
246
+ os.path.join(image_dir, "test") if image_dir else None
247
+ ),
248
+ "region_dir": (
249
+ os.path.join(region_dir, "test") if region_dir else None
250
+ ),
251
+ "grid_dir": (
252
+ os.path.join(grid_dir, "test") if grid_dir else None
253
+ ),
254
+ "labeled": False,
255
+ },
256
+ )
257
+ ]
258
+ else:
259
+ return datasets_split
260
+
261
  def _generate_examples(
262
  self, filepath, image_dir=None, region_dir=None, grid_dir=None, labeled=True
263
  ):