Tylersuard commited on
Commit
76318e3
·
1 Parent(s): 7ef56ff

Update PathfinderX2.py

Browse files
Files changed (1) hide show
  1. PathfinderX2.py +6 -5
PathfinderX2.py CHANGED
@@ -89,19 +89,20 @@ class PathfinderX2(datasets.GeneratorBasedBuilder):
89
  ]
90
 
91
  def _generate_examples(self, data, split):
92
- if split == "testing":
93
  images, annotations = data
94
- image_id2annot = {}
 
95
  # loads the annotations for the split into RAM (less than 100 MB) to support streaming
96
  for path_annot, file_annot in annotations:
97
  if path_annot.endswith(".png"):
98
  image_id = os.path.basename(path_annot).split(".")[0]
99
- image_id2annot[image_id] = (path_annot, file_annot.read())
100
  for idx, (path_img, file_img) in enumerate(images):
101
  if path_img.endswith(".png"):
102
  image_id = os.path.basename(path_img).split(".")[0]
103
- path_annot, bytes_annot = image_id2annot[image_id]
104
  yield idx, {
105
  "image": {"path": path_img, "bytes": file_img.read()},
106
- "annotation": None,
107
  }
 
89
  ]
90
 
91
  def _generate_examples(self, data, split):
92
+ if split == "training":
93
  images, annotations = data
94
+ image_dict = {}
95
+ annotation_dict = {}
96
  # loads the annotations for the split into RAM (less than 100 MB) to support streaming
97
  for path_annot, file_annot in annotations:
98
  if path_annot.endswith(".png"):
99
  image_id = os.path.basename(path_annot).split(".")[0]
100
+ annotation_dict[image_id] = (path_annot, file_annot.read())
101
  for idx, (path_img, file_img) in enumerate(images):
102
  if path_img.endswith(".png"):
103
  image_id = os.path.basename(path_img).split(".")[0]
104
+ path_annot, bytes_annot = image_dict[image_id]
105
  yield idx, {
106
  "image": {"path": path_img, "bytes": file_img.read()},
107
+ "annotation": {"path": path_annot, "bytes": file_annot.read()}
108
  }