Tylersuard
commited on
Commit
·
383bb88
1
Parent(s):
cdbfb65
Update PathfinderX2.py
Browse files- PathfinderX2.py +21 -18
PathfinderX2.py
CHANGED
@@ -89,7 +89,7 @@ class PathfinderX2(datasets.GeneratorBasedBuilder):
|
|
89 |
),
|
90 |
]
|
91 |
|
92 |
-
|
93 |
if split == "training":
|
94 |
images_dir, annotations_dir = data
|
95 |
image_dict = {}
|
@@ -102,20 +102,23 @@ class PathfinderX2(datasets.GeneratorBasedBuilder):
|
|
102 |
image_id = os.path.splitext(file_annot)[0]
|
103 |
annotation_dict[image_id] = os.path.join(root, file_annot)
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
89 |
),
|
90 |
]
|
91 |
|
92 |
+
def _generate_examples(self, data, split):
|
93 |
if split == "training":
|
94 |
images_dir, annotations_dir = data
|
95 |
image_dict = {}
|
|
|
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},
|
123 |
+
}
|
124 |
+
idx += 1
|