rshrott commited on
Commit
3f0c3b8
1 Parent(s): 06c0023

Update renovation.py

Browse files
Files changed (1) hide show
  1. renovation.py +6 -5
renovation.py CHANGED
@@ -6,6 +6,7 @@ from io import BytesIO
6
  from datasets.tasks import ImageClassification
7
  import pyarrow as pa
8
 
 
9
  _HOMEPAGE = "https://huggingface.co/datasets/rshrott/renovation"
10
 
11
  _CITATION = """\
@@ -36,6 +37,7 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
36
  description=_DESCRIPTION,
37
  features=datasets.Features(
38
  {
 
39
  "image": datasets.Value(pa.binary()),
40
  "label": datasets.features.ClassLabel(names=_NAMES),
41
  }
@@ -77,7 +79,7 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
77
  response = requests.get(url)
78
  img = Image.open(BytesIO(response.content))
79
  return img
80
-
81
  with open(filepath, "r") as f:
82
  reader = csv.reader(f)
83
  next(reader) # skip header
@@ -86,9 +88,9 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
86
  rows = rows[:int(0.8 * len(rows))]
87
  elif split == 'validation':
88
  rows = rows[int(0.8 * len(rows)):int(0.9 * len(rows))]
89
- else: # test
90
  rows = rows[int(0.9 * len(rows)):]
91
-
92
  for id_, row in enumerate(rows):
93
  if len(row) < 2:
94
  print(f"Row with id {id_} has less than 2 elements: {row}")
@@ -96,8 +98,7 @@ class RenovationQualityDataset(datasets.GeneratorBasedBuilder):
96
  image = url_to_image(row[0])
97
  image_bytes = image.tobytes()
98
  yield id_, {
99
- 'image_file_path': str(row[0]), # Convert to string
100
  'image': image_bytes,
101
  'label': row[1],
102
  }
103
-
 
6
  from datasets.tasks import ImageClassification
7
  import pyarrow as pa
8
 
9
+
10
  _HOMEPAGE = "https://huggingface.co/datasets/rshrott/renovation"
11
 
12
  _CITATION = """\
 
37
  description=_DESCRIPTION,
38
  features=datasets.Features(
39
  {
40
+ "image_file_path": datasets.Value("string"),
41
  "image": datasets.Value(pa.binary()),
42
  "label": datasets.features.ClassLabel(names=_NAMES),
43
  }
 
79
  response = requests.get(url)
80
  img = Image.open(BytesIO(response.content))
81
  return img
82
+
83
  with open(filepath, "r") as f:
84
  reader = csv.reader(f)
85
  next(reader) # skip header
 
88
  rows = rows[:int(0.8 * len(rows))]
89
  elif split == 'validation':
90
  rows = rows[int(0.8 * len(rows)):int(0.9 * len(rows))]
91
+ else: # test
92
  rows = rows[int(0.9 * len(rows)):]
93
+
94
  for id_, row in enumerate(rows):
95
  if len(row) < 2:
96
  print(f"Row with id {id_} has less than 2 elements: {row}")
 
98
  image = url_to_image(row[0])
99
  image_bytes = image.tobytes()
100
  yield id_, {
101
+ 'image_file_path': row[0],
102
  'image': image_bytes,
103
  'label': row[1],
104
  }