Tylersuard commited on
Commit
a93b607
·
1 Parent(s): 383bb88

Update PathfinderX2.py

Browse files
Files changed (1) hide show
  1. PathfinderX2.py +6 -6
PathfinderX2.py CHANGED
@@ -89,34 +89,34 @@ class PathfinderX2(datasets.GeneratorBasedBuilder):
89
  ),
90
  ]
91
 
92
- def _generate_examples(self, data, split):
93
  if split == "training":
94
  images_dir, annotations_dir = data
95
  image_dict = {}
96
  annotation_dict = {}
97
-
98
  # loads the annotations for the split into RAM (less than 100 MB) to support streaming
99
  for root, _, files in os.walk(annotations_dir):
100
  for file_annot in files:
101
  if file_annot.endswith(".png"):
102
  image_id = os.path.splitext(file_annot)[0]
103
  annotation_dict[image_id] = os.path.join(root, file_annot)
104
-
105
  idx = 0
106
  for root, _, files in os.walk(images_dir):
107
  for file_img in files:
108
  if file_img.endswith(".png"):
109
  image_id = os.path.splitext(file_img)[0]
110
  image_dict[image_id] = os.path.join(root, file_img)
111
-
112
  path_img = image_dict[image_id]
113
  path_annot = annotation_dict[image_id]
114
-
115
  with open(path_img, "rb") as f_img:
116
  bytes_img = f_img.read()
117
  with open(path_annot, "rb") as f_annot:
118
  bytes_annot = f_annot.read()
119
-
120
  yield idx, {
121
  "image": {"path": path_img, "bytes": bytes_img},
122
  "annotation": {"path": path_annot, "bytes": bytes_annot},
 
89
  ),
90
  ]
91
 
92
+ def _generate_examples(self, data, split):
93
  if split == "training":
94
  images_dir, annotations_dir = data
95
  image_dict = {}
96
  annotation_dict = {}
97
+
98
  # loads the annotations for the split into RAM (less than 100 MB) to support streaming
99
  for root, _, files in os.walk(annotations_dir):
100
  for file_annot in files:
101
  if file_annot.endswith(".png"):
102
  image_id = os.path.splitext(file_annot)[0]
103
  annotation_dict[image_id] = os.path.join(root, file_annot)
104
+
105
  idx = 0
106
  for root, _, files in os.walk(images_dir):
107
  for file_img in files:
108
  if file_img.endswith(".png"):
109
  image_id = os.path.splitext(file_img)[0]
110
  image_dict[image_id] = os.path.join(root, file_img)
111
+
112
  path_img = image_dict[image_id]
113
  path_annot = annotation_dict[image_id]
114
+
115
  with open(path_img, "rb") as f_img:
116
  bytes_img = f_img.read()
117
  with open(path_annot, "rb") as f_annot:
118
  bytes_annot = f_annot.read()
119
+
120
  yield idx, {
121
  "image": {"path": path_img, "bytes": bytes_img},
122
  "annotation": {"path": path_annot, "bytes": bytes_annot},