Update renovation.py
Browse files- renovation.py +27 -2
renovation.py
CHANGED
@@ -28,6 +28,8 @@ _NAMES = ["cheap", "average", "expensive"]
|
|
28 |
class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
|
29 |
"""Renovation Quality Dataset."""
|
30 |
|
|
|
|
|
31 |
def _info(self):
|
32 |
return datasets.DatasetInfo(
|
33 |
description=_DESCRIPTION,
|
@@ -50,15 +52,38 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
|
|
50 |
name=datasets.Split.TRAIN,
|
51 |
gen_kwargs={
|
52 |
"filepath": csv_path,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
},
|
54 |
),
|
55 |
]
|
56 |
|
57 |
-
def _generate_examples(self, filepath):
|
58 |
with open(filepath, "r") as f:
|
59 |
reader = csv.reader(f)
|
60 |
next(reader) # skip header
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
yield id_, {
|
63 |
'image': row[0],
|
64 |
'label': row[1],
|
|
|
28 |
class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
|
29 |
"""Renovation Quality Dataset."""
|
30 |
|
31 |
+
VERSION = datasets.Version("1.0.0")
|
32 |
+
|
33 |
def _info(self):
|
34 |
return datasets.DatasetInfo(
|
35 |
description=_DESCRIPTION,
|
|
|
52 |
name=datasets.Split.TRAIN,
|
53 |
gen_kwargs={
|
54 |
"filepath": csv_path,
|
55 |
+
"split": "train",
|
56 |
+
},
|
57 |
+
),
|
58 |
+
datasets.SplitGenerator(
|
59 |
+
name=datasets.Split.VALIDATION,
|
60 |
+
gen_kwargs={
|
61 |
+
"filepath": csv_path,
|
62 |
+
"split": "validation",
|
63 |
+
},
|
64 |
+
),
|
65 |
+
datasets.SplitGenerator(
|
66 |
+
name=datasets.Split.TEST,
|
67 |
+
gen_kwargs={
|
68 |
+
"filepath": csv_path,
|
69 |
+
"split": "test",
|
70 |
},
|
71 |
),
|
72 |
]
|
73 |
|
74 |
+
def _generate_examples(self, filepath, split):
|
75 |
with open(filepath, "r") as f:
|
76 |
reader = csv.reader(f)
|
77 |
next(reader) # skip header
|
78 |
+
rows = list(reader)
|
79 |
+
if split == 'train':
|
80 |
+
rows = rows[:int(0.8 * len(rows))]
|
81 |
+
elif split == 'validation':
|
82 |
+
rows = rows[int(0.8 * len(rows)):int(0.9 * len(rows))]
|
83 |
+
else: # test
|
84 |
+
rows = rows[int(0.9 * len(rows)):]
|
85 |
+
|
86 |
+
for id_, row in enumerate(rows):
|
87 |
yield id_, {
|
88 |
'image': row[0],
|
89 |
'label': row[1],
|