fix json loading
Browse files
SNLIVE.py
CHANGED
@@ -139,17 +139,17 @@ class SNLIVE(datasets.GeneratorBasedBuilder):
|
|
139 |
def _generate_examples(self, snli_ve_annotation_path, images_path):
|
140 |
counter = 0
|
141 |
print(snli_ve_annotation_path)
|
142 |
-
with open(snli_ve_annotation_path,
|
143 |
-
|
144 |
-
for elem in data:
|
145 |
elem = json.loads(elem)
|
146 |
img_filename = str(elem["Flickr30K_ID"]) + ".jpg"
|
147 |
assert os.path.exists(os.path.join(images_path, img_filename))
|
148 |
-
|
149 |
"image": os.path.join(images_path, img_filename),
|
150 |
"filename": img_filename,
|
151 |
"premise": elem["sentence1"],
|
152 |
"hypothesis": elem["sentence2"],
|
153 |
"label": elem["gold_label"],
|
154 |
}
|
|
|
155 |
counter += 1
|
|
|
139 |
def _generate_examples(self, snli_ve_annotation_path, images_path):
|
140 |
counter = 0
|
141 |
print(snli_ve_annotation_path)
|
142 |
+
with open(snli_ve_annotation_path, 'r') as json_file:
|
143 |
+
for elem in json_file:
|
|
|
144 |
elem = json.loads(elem)
|
145 |
img_filename = str(elem["Flickr30K_ID"]) + ".jpg"
|
146 |
assert os.path.exists(os.path.join(images_path, img_filename))
|
147 |
+
record = {
|
148 |
"image": os.path.join(images_path, img_filename),
|
149 |
"filename": img_filename,
|
150 |
"premise": elem["sentence1"],
|
151 |
"hypothesis": elem["sentence2"],
|
152 |
"label": elem["gold_label"],
|
153 |
}
|
154 |
+
yield counter, record
|
155 |
counter += 1
|