Update renovation.py
Browse files- 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 |
-
|
81 |
for label, path in data_files.items():
|
82 |
files = glob.glob(path + '/*.jpeg', recursive=True)
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
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 |
|