Update ecoset.py
Browse files
ecoset.py
CHANGED
@@ -209,15 +209,14 @@ class Ecoset(datasets.GeneratorBasedBuilder):
|
|
209 |
idx = 0
|
210 |
split_archives = os.path.join(archives, split)
|
211 |
acceptable_formats = [".JPEG", ".JPG", ".jpeg", ".jpg"]
|
212 |
-
|
213 |
for subdirectory, dirs, files in os.walk(split_archives):
|
214 |
label = subdirectory.rsplit('_', 1)[-1]
|
215 |
for file in files:
|
216 |
if any(file.endswith(f) for f in acceptable_formats):
|
217 |
file_path = os.path.join(subdirectory, file)
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
ex = {"image": {"path": rel_path, "bytes": file_handle.read()}, "label": label}
|
222 |
yield idx, ex
|
223 |
idx += 1
|
|
|
209 |
idx = 0
|
210 |
split_archives = os.path.join(archives, split)
|
211 |
acceptable_formats = [".JPEG", ".JPG", ".jpeg", ".jpg"]
|
212 |
+
|
213 |
for subdirectory, dirs, files in os.walk(split_archives):
|
214 |
label = subdirectory.rsplit('_', 1)[-1]
|
215 |
for file in files:
|
216 |
if any(file.endswith(f) for f in acceptable_formats):
|
217 |
file_path = os.path.join(subdirectory, file)
|
218 |
+
abs_path = os.path.abspath(file_path) # Convert to absolute path
|
219 |
+
with open(abs_path, 'rb') as file_handle:
|
220 |
+
ex = {"image": {"path": abs_path, "bytes": file_handle.read()}, "label": label}
|
|
|
221 |
yield idx, ex
|
222 |
idx += 1
|