Datasets:
frgfm
commited on
Commit
•
82696b5
1
Parent(s):
8553c95
fix: Fixed preview
Browse files- imagenette.py +10 -5
imagenette.py
CHANGED
@@ -112,25 +112,30 @@ 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 |
-
|
116 |
return [
|
117 |
datasets.SplitGenerator(
|
118 |
name=datasets.Split.TRAIN,
|
119 |
gen_kwargs={
|
120 |
-
"archive_iter":
|
|
|
121 |
},
|
122 |
),
|
123 |
datasets.SplitGenerator(
|
124 |
name=datasets.Split.VALIDATION,
|
125 |
gen_kwargs={
|
126 |
-
"archive_iter":
|
|
|
127 |
},
|
128 |
),
|
129 |
]
|
130 |
|
131 |
-
def _generate_examples(self, archive_iter):
|
132 |
idx = 0
|
133 |
for path, f in archive_iter:
|
134 |
-
|
|
|
|
|
|
|
135 |
yield idx, {"image": path, "label": class_idx}
|
136 |
idx += 1
|
|
|
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_iter = dl_manager.iter_archive(archive_path)
|
116 |
return [
|
117 |
datasets.SplitGenerator(
|
118 |
name=datasets.Split.TRAIN,
|
119 |
gen_kwargs={
|
120 |
+
"archive_iter": archive_iter,
|
121 |
+
"split_folder": "train",
|
122 |
},
|
123 |
),
|
124 |
datasets.SplitGenerator(
|
125 |
name=datasets.Split.VALIDATION,
|
126 |
gen_kwargs={
|
127 |
+
"archive_iter": archive_iter,
|
128 |
+
"split_folder": "val",
|
129 |
},
|
130 |
),
|
131 |
]
|
132 |
|
133 |
+
def _generate_examples(self, archive_iter, split_folder):
|
134 |
idx = 0
|
135 |
for path, f in archive_iter:
|
136 |
+
path_split = path.split("/")
|
137 |
+
if path_split[-3] != split_folder:
|
138 |
+
continue
|
139 |
+
class_idx = _LABEL_MAP.index(path_split[-2])
|
140 |
yield idx, {"image": path, "label": class_idx}
|
141 |
idx += 1
|