Jinchen Ge commited on
Commit
1d2a45f
·
1 Parent(s): 1b59541

Start to add test subset

Browse files
Files changed (1) hide show
  1. gqa-lxmert.py +14 -5
gqa-lxmert.py CHANGED
@@ -44,12 +44,14 @@ seeking to address key shortcomings of previous visual question answering (VQA)
44
 
45
  _URLS = {
46
  "train": "https://nlp.cs.unc.edu/data/lxmert_data/gqa/train.json",
47
- "dev": "https://nlp.cs.unc.edu/data/lxmert_data/gqa/valid.json",
48
- "feat": "https://nlp.cs.unc.edu/data/lxmert_data/vg_gqa_imgfeat/vg_gqa_obj36.zip",
 
 
49
  "ans2label": "https://raw.githubusercontent.com/airsplay/lxmert/master/data/gqa/trainval_ans2label.json",
50
  }
51
 
52
- _FEAT_PATH = "vg_gqa_imgfeat/vg_gqa_obj36.tsv"
53
 
54
  FIELDNAMES = [
55
  "img_id", "img_h", "img_w", "objects_id", "objects_conf", "attrs_id", "attrs_conf", "num_boxes", "boxes", "features"
@@ -132,8 +134,15 @@ class GqaLxmert(datasets.GeneratorBasedBuilder):
132
  with open(filepath, encoding="utf-8") as f:
133
  gqa = json.load(f)
134
  for id_, d in enumerate(gqa):
135
- img_features = self.id2features[d["img_id"]]
136
- label = self.ans2label[next(iter(d["label"]))]
 
 
 
 
 
 
 
137
  yield id_, {
138
  "question": d["sent"],
139
  "question_id": d["question_id"],
 
44
 
45
  _URLS = {
46
  "train": "https://nlp.cs.unc.edu/data/lxmert_data/gqa/train.json",
47
+ "val": "https://nlp.cs.unc.edu/data/lxmert_data/gqa/valid.json",
48
+ "trainval_feat": "https://nlp.cs.unc.edu/data/lxmert_data/vg_gqa_imgfeat/vg_gqa_obj36.zip",
49
+ "test": "https://nlp.cs.unc.edu/data/lxmert_data/gqa/testdev.json",
50
+ "test_feat": "https://nlp.cs.unc.edu/data/lxmert_data/vg_gqa_imgfeat/gqa_testdev_obj36.zip",
51
  "ans2label": "https://raw.githubusercontent.com/airsplay/lxmert/master/data/gqa/trainval_ans2label.json",
52
  }
53
 
54
+ _FEAT_PATH = "vg_gqa_imgfeat/gqa_testdev_obj36.tsv"
55
 
56
  FIELDNAMES = [
57
  "img_id", "img_h", "img_w", "objects_id", "objects_conf", "attrs_id", "attrs_conf", "num_boxes", "boxes", "features"
 
134
  with open(filepath, encoding="utf-8") as f:
135
  gqa = json.load(f)
136
  for id_, d in enumerate(gqa):
137
+ try:
138
+ img_features = self.id2features[d["img_id"]]
139
+ except KeyError:
140
+ continue
141
+ label_key = next(iter(d["label"]))
142
+ if label_key not in self.ans2label:
143
+ print ("Ignored one label")
144
+ continue
145
+ label = self.ans2label[label_key]
146
  yield id_, {
147
  "question": d["sent"],
148
  "question_id": d["question_id"],