Datasets:
frgfm
commited on
Commit
·
44d0482
1
Parent(s):
82696b5
fix: Fixed preview
Browse files- imagenette.py +8 -15
imagenette.py
CHANGED
@@ -110,32 +110,25 @@ class OpenFire(datasets.GeneratorBasedBuilder):
|
|
110 |
)
|
111 |
|
112 |
def _split_generators(self, dl_manager):
|
113 |
-
|
114 |
-
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
|
115 |
-
archive_iter = dl_manager.iter_archive(archive_path)
|
116 |
return [
|
117 |
datasets.SplitGenerator(
|
118 |
name=datasets.Split.TRAIN,
|
119 |
gen_kwargs={
|
120 |
-
"
|
121 |
-
"split_folder": "train",
|
122 |
},
|
123 |
),
|
124 |
datasets.SplitGenerator(
|
125 |
name=datasets.Split.VALIDATION,
|
126 |
gen_kwargs={
|
127 |
-
"
|
128 |
-
"split_folder": "val",
|
129 |
},
|
130 |
),
|
131 |
]
|
132 |
|
133 |
-
def _generate_examples(self,
|
134 |
idx = 0
|
135 |
-
for
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
class_idx = _LABEL_MAP.index(path_split[-2])
|
140 |
-
yield idx, {"image": path, "label": class_idx}
|
141 |
-
idx += 1
|
|
|
110 |
)
|
111 |
|
112 |
def _split_generators(self, dl_manager):
|
113 |
+
local_extracted_archive = dl_manager.download_and_extract(self.config.data_url)
|
|
|
|
|
114 |
return [
|
115 |
datasets.SplitGenerator(
|
116 |
name=datasets.Split.TRAIN,
|
117 |
gen_kwargs={
|
118 |
+
"split_folder": os.path.join(local_extracted_archive, "train"),
|
|
|
119 |
},
|
120 |
),
|
121 |
datasets.SplitGenerator(
|
122 |
name=datasets.Split.VALIDATION,
|
123 |
gen_kwargs={
|
124 |
+
"split_folder": os.path.join(local_extracted_archive, "val"),
|
|
|
125 |
},
|
126 |
),
|
127 |
]
|
128 |
|
129 |
+
def _generate_examples(self, split_folder):
|
130 |
idx = 0
|
131 |
+
for class_idx, class_folder in enumerate(_LABEL_MAP):
|
132 |
+
for path in os.listdir(os.path.join(split_folder, class_folder)):
|
133 |
+
yield idx, {"image": os.path.join(split_folder, class_folder, path), "label": class_idx}
|
134 |
+
idx += 1
|
|
|
|
|
|