Leyo commited on
Commit
d85b64c
·
1 Parent(s): 8eb3b9d

only yield existing paths

Browse files
Files changed (1) hide show
  1. NLVR2.py +10 -9
NLVR2.py CHANGED
@@ -125,12 +125,13 @@ class NLVR2Dataset(datasets.GeneratorBasedBuilder):
125
  right_img_identifier = f"{split_name}-{common_img_identifier[1]}-{common_img_identifier[2]}-img1.png"
126
  left_image_path = str(os.path.join(images_path, left_img_identifier))
127
  right_image_path = str(os.path.join(images_path, right_img_identifier))
128
- record = {
129
- "identifier": ex["identifier"],
130
- "sentence": ex["sentence"],
131
- "left_image": left_image_path,
132
- "right_image": right_image_path,
133
- "label": ex["label"],
134
- }
135
- idx += 1
136
- yield idx, record
 
 
125
  right_img_identifier = f"{split_name}-{common_img_identifier[1]}-{common_img_identifier[2]}-img1.png"
126
  left_image_path = str(os.path.join(images_path, left_img_identifier))
127
  right_image_path = str(os.path.join(images_path, right_img_identifier))
128
+ if os.path.exists(left_image_path) and os.path.exists(right_image_path):
129
+ record = {
130
+ "identifier": ex["identifier"],
131
+ "sentence": ex["sentence"],
132
+ "left_image": left_image_path,
133
+ "right_image": right_image_path,
134
+ "label": ex["label"],
135
+ }
136
+ idx += 1
137
+ yield idx, record