Datasets:
frgfm
commited on
Commit
•
8553c95
1
Parent(s):
503071a
fix: Fixed preview
Browse files- imagenette.py +8 -9
imagenette.py
CHANGED
@@ -112,26 +112,25 @@ class OpenFire(datasets.GeneratorBasedBuilder):
|
|
112 |
def _split_generators(self, dl_manager):
|
113 |
archive_path = dl_manager.download(self.config.data_url)
|
114 |
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
|
|
|
115 |
return [
|
116 |
datasets.SplitGenerator(
|
117 |
name=datasets.Split.TRAIN,
|
118 |
gen_kwargs={
|
119 |
-
"
|
120 |
-
"split": "train",
|
121 |
},
|
122 |
),
|
123 |
datasets.SplitGenerator(
|
124 |
name=datasets.Split.VALIDATION,
|
125 |
gen_kwargs={
|
126 |
-
"
|
127 |
-
"split": "validation",
|
128 |
},
|
129 |
),
|
130 |
]
|
131 |
|
132 |
-
def _generate_examples(self,
|
133 |
idx = 0
|
134 |
-
for
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
112 |
def _split_generators(self, dl_manager):
|
113 |
archive_path = dl_manager.download(self.config.data_url)
|
114 |
local_extracted_archive = dl_manager.extract(archive_path) if not dl_manager.is_streaming else None
|
115 |
+
archive_iters = {l: dl_manager.iter_archive(v) for l, v in archive_path.items()}
|
116 |
return [
|
117 |
datasets.SplitGenerator(
|
118 |
name=datasets.Split.TRAIN,
|
119 |
gen_kwargs={
|
120 |
+
"archive_iter": archive_iters["train"],
|
|
|
121 |
},
|
122 |
),
|
123 |
datasets.SplitGenerator(
|
124 |
name=datasets.Split.VALIDATION,
|
125 |
gen_kwargs={
|
126 |
+
"archive_iter": archive_iters["val"],
|
|
|
127 |
},
|
128 |
),
|
129 |
]
|
130 |
|
131 |
+
def _generate_examples(self, archive_iter):
|
132 |
idx = 0
|
133 |
+
for path, f in archive_iter:
|
134 |
+
class_idx = _LABEL_MAP.index(path.split("/")[-2])
|
135 |
+
yield idx, {"image": path, "label": class_idx}
|
136 |
+
idx += 1
|