rshrott commited on
Commit
f4ce00e
1 Parent(s): fe9bc2b

Update renovation.py

Browse files
Files changed (1) hide show
  1. renovation.py +5 -9
renovation.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
 
3
  import datasets
4
  from datasets.tasks import ImageClassification
@@ -29,8 +30,6 @@ _URLS = {
29
 
30
  _NAMES = ["cheap", "average", "expensive"]
31
 
32
- import glob
33
-
34
  class Renovations(datasets.GeneratorBasedBuilder):
35
  """Renovations house images dataset."""
36
 
@@ -56,19 +55,19 @@ class Renovations(datasets.GeneratorBasedBuilder):
56
  datasets.SplitGenerator(
57
  name=datasets.Split.TRAIN,
58
  gen_kwargs={
59
- "files": glob.glob(data_files["cheap"] + '/**/*.jpeg', recursive=True),
60
  },
61
  ),
62
  datasets.SplitGenerator(
63
  name=datasets.Split.VALIDATION,
64
  gen_kwargs={
65
- "files": glob.glob(data_files["average"] + '/**/*.jpeg', recursive=True),
66
  },
67
  ),
68
  datasets.SplitGenerator(
69
  name=datasets.Split.TEST,
70
  gen_kwargs={
71
- "files": glob.glob(data_files["expensive"] + '/**/*.jpeg', recursive=True),
72
  },
73
  ),
74
  ]
@@ -77,13 +76,10 @@ class Renovations(datasets.GeneratorBasedBuilder):
77
  print(f"Processing {len(files)} files:")
78
  for i, path in enumerate(files):
79
  print(f"Processing file {i}: {path}")
80
- label = os.path.basename(os.path.dirname(os.path.dirname(path))).lower()
81
  print(f"Label: {label}")
82
  yield i, {
83
  "image_file_path": path,
84
  "image": path,
85
  "labels": label,
86
  }
87
-
88
-
89
-
 
1
  import os
2
+ import glob
3
 
4
  import datasets
5
  from datasets.tasks import ImageClassification
 
30
 
31
  _NAMES = ["cheap", "average", "expensive"]
32
 
 
 
33
  class Renovations(datasets.GeneratorBasedBuilder):
34
  """Renovations house images dataset."""
35
 
 
55
  datasets.SplitGenerator(
56
  name=datasets.Split.TRAIN,
57
  gen_kwargs={
58
+ "files": glob.glob(data_files["cheap"] + '/*.jpeg', recursive=True),
59
  },
60
  ),
61
  datasets.SplitGenerator(
62
  name=datasets.Split.VALIDATION,
63
  gen_kwargs={
64
+ "files": glob.glob(data_files["average"] + '/*.jpeg', recursive=True),
65
  },
66
  ),
67
  datasets.SplitGenerator(
68
  name=datasets.Split.TEST,
69
  gen_kwargs={
70
+ "files": glob.glob(data_files["expensive"] + '/*.jpeg', recursive=True),
71
  },
72
  ),
73
  ]
 
76
  print(f"Processing {len(files)} files:")
77
  for i, path in enumerate(files):
78
  print(f"Processing file {i}: {path}")
79
+ label = os.path.basename(os.path.dirname(path)).lower()
80
  print(f"Label: {label}")
81
  yield i, {
82
  "image_file_path": path,
83
  "image": path,
84
  "labels": label,
85
  }