rshrott commited on
Commit
bce72ea
·
verified ·
1 Parent(s): e618532

Update renovation.py

Browse files
Files changed (1) hide show
  1. renovation.py +4 -5
renovation.py CHANGED
@@ -85,12 +85,11 @@ class Renovations(datasets.GeneratorBasedBuilder):
85
  all_files_and_labels = []
86
  for label, zip_path in data_files.items():
87
  with zipfile.ZipFile(zip_path, "r") as zip_ref:
88
- # Get the folder name inside the zip file
89
- folder_name = zip_ref.namelist()[0].split("/")[0]
90
- files = zip_ref.namelist()
91
- files = [f for f in files if f.startswith(folder_name + "/") and f.endswith(".jpeg")]
92
  for file in files:
93
- all_files_and_labels.append((zip_ref.extract(file), label))
 
94
 
95
  random.seed(43) # ensure reproducibility
96
  random.shuffle(all_files_and_labels)
 
85
  all_files_and_labels = []
86
  for label, zip_path in data_files.items():
87
  with zipfile.ZipFile(zip_path, "r") as zip_ref:
88
+ folder_name = os.path.splitext(os.path.basename(zip_path))[0] # Get the folder name without extension
89
+ files = [f for f in zip_ref.namelist() if f.startswith(folder_name + "/") and f.endswith(".jpeg")]
 
 
90
  for file in files:
91
+ file_path = os.path.join(self.config.data_dir, os.path.basename(zip_path)[:-4], file)
92
+ all_files_and_labels.append((file_path, label))
93
 
94
  random.seed(43) # ensure reproducibility
95
  random.shuffle(all_files_and_labels)