Update renovation.py
Browse files- renovation.py +11 -4
renovation.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import csv
|
|
|
2 |
import datasets
|
3 |
import requests
|
4 |
import os
|
@@ -7,7 +8,6 @@ from PIL import Image
|
|
7 |
from io import BytesIO
|
8 |
from datasets.tasks import ImageClassification
|
9 |
|
10 |
-
|
11 |
_HOMEPAGE = "https://huggingface.co/datasets/rshrott/renovation"
|
12 |
|
13 |
_CITATION = """\
|
@@ -56,23 +56,30 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
|
|
56 |
next(reader) # skip header
|
57 |
rows = list(reader)
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
return [
|
60 |
datasets.SplitGenerator(
|
61 |
name=datasets.Split.TRAIN,
|
62 |
gen_kwargs={
|
63 |
-
"rows": rows[:
|
64 |
},
|
65 |
),
|
66 |
datasets.SplitGenerator(
|
67 |
name=datasets.Split.VALIDATION,
|
68 |
gen_kwargs={
|
69 |
-
"rows": rows[
|
70 |
},
|
71 |
),
|
72 |
datasets.SplitGenerator(
|
73 |
name=datasets.Split.TEST,
|
74 |
gen_kwargs={
|
75 |
-
"rows": rows[
|
76 |
},
|
77 |
),
|
78 |
]
|
|
|
1 |
import csv
|
2 |
+
import random
|
3 |
import datasets
|
4 |
import requests
|
5 |
import os
|
|
|
8 |
from io import BytesIO
|
9 |
from datasets.tasks import ImageClassification
|
10 |
|
|
|
11 |
_HOMEPAGE = "https://huggingface.co/datasets/rshrott/renovation"
|
12 |
|
13 |
_CITATION = """\
|
|
|
56 |
next(reader) # skip header
|
57 |
rows = list(reader)
|
58 |
|
59 |
+
# Shuffle rows
|
60 |
+
random.shuffle(rows)
|
61 |
+
|
62 |
+
# 80% for training, 10% for validation, 10% for testing
|
63 |
+
train_end = int(0.8 * len(rows))
|
64 |
+
val_end = int(0.9 * len(rows))
|
65 |
+
|
66 |
return [
|
67 |
datasets.SplitGenerator(
|
68 |
name=datasets.Split.TRAIN,
|
69 |
gen_kwargs={
|
70 |
+
"rows": rows[:train_end],
|
71 |
},
|
72 |
),
|
73 |
datasets.SplitGenerator(
|
74 |
name=datasets.Split.VALIDATION,
|
75 |
gen_kwargs={
|
76 |
+
"rows": rows[train_end:val_end],
|
77 |
},
|
78 |
),
|
79 |
datasets.SplitGenerator(
|
80 |
name=datasets.Split.TEST,
|
81 |
gen_kwargs={
|
82 |
+
"rows": rows[val_end:],
|
83 |
},
|
84 |
),
|
85 |
]
|