only yield existing paths
Browse files
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 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
| 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
|