vkapoor commited on
Commit
a6568f8
·
1 Parent(s): 73a3818

Update ecoset.py

Browse files
Files changed (1) hide show
  1. ecoset.py +4 -5
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
- # Calculate the relative path from the base directory
219
- rel_path = os.path.relpath(file_path, split_archives)
220
- with open(file_path, 'rb') as file_handle:
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