Update ecoset.py
Browse files
ecoset.py
CHANGED
@@ -212,18 +212,18 @@ class Ecoset(datasets.GeneratorBasedBuilder):
|
|
212 |
"""Yields examples."""
|
213 |
idx = 0
|
214 |
split_archives = os.path.join(archives, split)
|
215 |
-
|
216 |
acceptable_formats = [".JPEG", ".JPG", ".jpeg", ".jpg"]
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
#
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
212 |
"""Yields examples."""
|
213 |
idx = 0
|
214 |
split_archives = os.path.join(archives, split)
|
|
|
215 |
acceptable_formats = [".JPEG", ".JPG", ".jpeg", ".jpg"]
|
216 |
+
|
217 |
+
for subdirectory in os.listdir(split_archives):
|
218 |
+
subdirectory_path = os.path.join(split_archives, subdirectory)
|
219 |
+
if os.path.isdir(subdirectory_path):
|
220 |
+
label = subdirectory # Assuming the folder name is the label
|
221 |
+
|
222 |
+
for file in os.listdir(subdirectory_path):
|
223 |
+
if any(file.endswith(f) for f in acceptable_formats):
|
224 |
+
|
225 |
+
file_path = os.path.join(subdirectory_path, file)
|
226 |
+
with open(file_path, 'rb') as file_handle:
|
227 |
+
ex = {"image": {"path": file_path, "bytes": file_handle.read()}, "label": label}
|
228 |
+
yield idx, ex
|
229 |
+
idx += 1
|