rshrott commited on
Commit
a9126ce
1 Parent(s): 4b10b88

Update renovation.py

Browse files
Files changed (1) hide show
  1. renovation.py +20 -17
renovation.py CHANGED
@@ -77,24 +77,27 @@ class Renovations(datasets.GeneratorBasedBuilder):
77
  ]
78
 
79
  def _generate_examples(self, data_files, split):
80
- idx = 0
81
  for label, path in data_files.items():
82
  files = glob.glob(path + '/*.jpeg', recursive=True)
83
- random.shuffle(files)
84
- num_files = len(files)
85
- if split == "train":
86
- files = files[:int(num_files*0.7)]
87
- elif split == "val":
88
- files = files[int(num_files*0.7):int(num_files*0.85)]
89
- else:
90
- files = files[int(num_files*0.85):]
91
-
92
- for file in files:
93
- yield idx, {
94
- "image_file_path": file,
95
- "image": file,
96
- "labels": label,
97
- }
98
- idx += 1
 
 
 
99
 
100
 
 
77
  ]
78
 
79
  def _generate_examples(self, data_files, split):
80
+ all_files_and_labels = []
81
  for label, path in data_files.items():
82
  files = glob.glob(path + '/*.jpeg', recursive=True)
83
+ all_files_and_labels.extend((file, label) for file in files)
84
+
85
+ random.shuffle(all_files_and_labels)
86
+
87
+ num_files = len(all_files_and_labels)
88
+ if split == "train":
89
+ all_files_and_labels = all_files_and_labels[:int(num_files*0.7)]
90
+ elif split == "val":
91
+ all_files_and_labels = all_files_and_labels[int(num_files*0.7):int(num_files*0.85)]
92
+ else:
93
+ all_files_and_labels = all_files_and_labels[int(num_files*0.85):]
94
+
95
+ for idx, (file, label) in enumerate(all_files_and_labels):
96
+ yield idx, {
97
+ "image_file_path": file,
98
+ "image": file,
99
+ "labels": label,
100
+ }
101
+
102
 
103