Tylersuard commited on
Commit
8cc08a7
·
1 Parent(s): 3ebbc67

Update PathfinderX2.py

Browse files
Files changed (1) hide show
  1. PathfinderX2.py +12 -4
PathfinderX2.py CHANGED
@@ -106,12 +106,20 @@ class PathfinderX2(datasets.GeneratorBasedBuilder):
106
  def _generate_examples(self, data, split):
107
  if split == "testing":
108
  images, annotations = data
109
- for idx, (path, file) in enumerate(data):
110
- if path.endswith(".png"):
 
 
 
 
 
 
 
 
111
  yield idx, {
112
- "image": {"path": path, "bytes": file.read()},
113
  "annotation": None,
114
- }
115
  else:
116
  images, annotations = data
117
  image_id2annot = {}
 
106
  def _generate_examples(self, data, split):
107
  if split == "testing":
108
  images, annotations = data
109
+ image_id2annot = {}
110
+ # loads the annotations for the split into RAM (less than 100 MB) to support streaming
111
+ for path_annot, file_annot in annotations:
112
+ if split in path_annot and path_annot.endswith(".png"):
113
+ image_id = os.path.basename(path_annot).split(".")[0]
114
+ image_id2annot[image_id] = (path_annot, file_annot.read())
115
+ for idx, (path_img, file_img) in enumerate(images):
116
+ if split in path_img and path_img.endswith(".png"):
117
+ image_id = os.path.basename(path_img).split(".")[0]
118
+ path_annot, bytes_annot = image_id2annot[image_id]
119
  yield idx, {
120
+ "image": {"path": path_img, "bytes": file_img.read()},
121
  "annotation": None,
122
+ }
123
  else:
124
  images, annotations = data
125
  image_id2annot = {}