rshrott commited on
Commit
fc74c6f
1 Parent(s): ff0db53

Create renovation.py

Browse files
Files changed (1) hide show
  1. renovation.py +65 -0
renovation.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import csv
3
+
4
+ import datasets
5
+ from datasets.tasks import ImageClassification
6
+
7
+
8
+ _HOMEPAGE = "https://huggingface.co/datasets/rshrott/renovation"
9
+
10
+ _CITATION = """\
11
+ @ONLINE {renovationquality,
12
+ author="Your Name",
13
+ title="Renovation Quality Dataset",
14
+ month="Your Month",
15
+ year="Your Year",
16
+ url="https://huggingface.co/datasets/rshrott/renovation"
17
+ }
18
+ """
19
+
20
+ _DESCRIPTION = """\
21
+ This dataset contains images of various properties, along with labels indicating the quality of renovation - 'cheap', 'average', 'expensive'.
22
+ """
23
+
24
+ _URL = "https://huggingface.co/datasets/rshrott/renovation/blob/main/labels.csv"
25
+
26
+ _NAMES = ["cheap", "average", "expensive"]
27
+
28
+ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
29
+ """Renovation Quality Dataset."""
30
+
31
+ def _info(self):
32
+ return datasets.DatasetInfo(
33
+ description=_DESCRIPTION,
34
+ features=datasets.Features(
35
+ {
36
+ "image": datasets.Value("string"),
37
+ "label": datasets.features.ClassLabel(names=_NAMES),
38
+ }
39
+ ),
40
+ supervised_keys=("image", "label"),
41
+ homepage=_HOMEPAGE,
42
+ citation=_CITATION,
43
+ task_templates=[ImageClassification(image_column="image", label_column="label")],
44
+ )
45
+
46
+ def _split_generators(self, dl_manager):
47
+ csv_path = dl_manager.download(_URL)
48
+ return [
49
+ datasets.SplitGenerator(
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
+ for id_, row in enumerate(reader):
62
+ yield id_, {
63
+ 'image': row[0],
64
+ 'label': row[1],
65
+ }