Update renovation.py
Browse files- renovation.py +17 -15
renovation.py
CHANGED
@@ -19,17 +19,21 @@ _CITATION = """\
|
|
19 |
|
20 |
_DESCRIPTION = """\
|
21 |
Renovations is a dataset of images of houses taken in the field using smartphone
|
22 |
-
cameras. It consists of
|
23 |
Data was collected by the your research lab.
|
24 |
"""
|
25 |
|
26 |
_URLS = {
|
27 |
-
"
|
28 |
-
"
|
29 |
-
"
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
-
_NAMES = ["
|
33 |
|
34 |
class Renovations(datasets.GeneratorBasedBuilder):
|
35 |
"""Renovations house images dataset."""
|
@@ -75,32 +79,30 @@ class Renovations(datasets.GeneratorBasedBuilder):
|
|
75 |
},
|
76 |
),
|
77 |
]
|
|
|
78 |
def _generate_examples(self, data_files, split):
|
79 |
all_files_and_labels = []
|
80 |
for label, path in data_files.items():
|
81 |
files = glob.glob(path + '/*.jpeg', recursive=True)
|
82 |
all_files_and_labels.extend((file, label) for file in files)
|
83 |
-
|
84 |
random.seed(43) # ensure reproducibility
|
85 |
random.shuffle(all_files_and_labels)
|
86 |
-
|
87 |
num_files = len(all_files_and_labels)
|
88 |
train_data = all_files_and_labels[:int(num_files*0.9)]
|
89 |
-
val_test_data = all_files_and_labels[int(num_files*0.9):]
|
90 |
-
|
91 |
if split == "train":
|
92 |
data_to_use = train_data
|
93 |
-
else:
|
94 |
data_to_use = val_test_data
|
95 |
-
|
96 |
for idx, (file, label) in enumerate(data_to_use):
|
97 |
yield idx, {
|
98 |
"image_file_path": file,
|
99 |
"image": file,
|
100 |
"labels": label,
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
|
|
|
19 |
|
20 |
_DESCRIPTION = """\
|
21 |
Renovations is a dataset of images of houses taken in the field using smartphone
|
22 |
+
cameras. It consists of 7 classes: Not Applicable, Very Poor, Poor, Fair, Good, Excellent, and Exceptional renovations.
|
23 |
Data was collected by the your research lab.
|
24 |
"""
|
25 |
|
26 |
_URLS = {
|
27 |
+
"Not Applicable": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Not Applicable.zip",
|
28 |
+
"Very Poor": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Very Poor.zip",
|
29 |
+
"Poor": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Poor.zip",
|
30 |
+
"Fair": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Fair.zip",
|
31 |
+
"Good": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Good.zip",
|
32 |
+
"Excellent": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Excellent.zip",
|
33 |
+
"Exceptional": "https://huggingface.co/datasets/rshrott/photos/resolve/main/Exceptional.zip"
|
34 |
}
|
35 |
|
36 |
+
_NAMES = ["Not Applicable", "Very Poor", "Poor", "Fair", "Good", "Excellent", "Exceptional"]
|
37 |
|
38 |
class Renovations(datasets.GeneratorBasedBuilder):
|
39 |
"""Renovations house images dataset."""
|
|
|
79 |
},
|
80 |
),
|
81 |
]
|
82 |
+
|
83 |
def _generate_examples(self, data_files, split):
|
84 |
all_files_and_labels = []
|
85 |
for label, path in data_files.items():
|
86 |
files = glob.glob(path + '/*.jpeg', recursive=True)
|
87 |
all_files_and_labels.extend((file, label) for file in files)
|
88 |
+
|
89 |
random.seed(43) # ensure reproducibility
|
90 |
random.shuffle(all_files_and_labels)
|
91 |
+
|
92 |
num_files = len(all_files_and_labels)
|
93 |
train_data = all_files_and_labels[:int(num_files*0.9)]
|
94 |
+
val_test_data = all_files_and_labels[int(num_files*0.9):] # This will be used for both val and test
|
95 |
+
|
96 |
if split == "train":
|
97 |
data_to_use = train_data
|
98 |
+
else: # "val" or "test" split
|
99 |
data_to_use = val_test_data
|
100 |
+
|
101 |
for idx, (file, label) in enumerate(data_to_use):
|
102 |
yield idx, {
|
103 |
"image_file_path": file,
|
104 |
"image": file,
|
105 |
"labels": label,
|
106 |
+
}
|
|
|
|
|
|
|
107 |
|
108 |
|