Datasets:
Tasks:
Image Classification
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
10M<n<100M
ArXiv:
License:
Commit
·
83b2798
1
Parent(s):
059cb70
Make script parallelizable (#3)
Browse files- Make script parallelizable (b89324d4754d89c8332d8b2999b22353946d5809)
- quickdraw.py +6 -4
quickdraw.py
CHANGED
|
@@ -246,6 +246,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 246 |
files = dl_manager.download(
|
| 247 |
{name: url for name, url in zip(_NAMES, [base_url.format(name) for name in _NAMES])}
|
| 248 |
)
|
|
|
|
| 249 |
return [
|
| 250 |
datasets.SplitGenerator(
|
| 251 |
name=datasets.Split.TRAIN,
|
|
@@ -259,6 +260,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 259 |
files = dl_manager.download_and_extract(
|
| 260 |
{name: url for name, url in zip(_NAMES, [base_url.format(name) for name in _NAMES])}
|
| 261 |
)
|
|
|
|
| 262 |
return [
|
| 263 |
datasets.SplitGenerator(
|
| 264 |
name=datasets.Split.TRAIN,
|
|
@@ -286,7 +288,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 286 |
def _generate_examples(self, files, split):
|
| 287 |
if self.config.name == "raw":
|
| 288 |
idx = 0
|
| 289 |
-
for _, file in files
|
| 290 |
with open(file, encoding="utf-8") as f:
|
| 291 |
for line in f:
|
| 292 |
example = json.loads(line)
|
|
@@ -296,7 +298,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 296 |
idx += 1
|
| 297 |
elif self.config.name == "preprocessed_simplified_drawings":
|
| 298 |
idx = 0
|
| 299 |
-
for label, file in files
|
| 300 |
with open(file, "rb") as f:
|
| 301 |
while True:
|
| 302 |
try:
|
|
@@ -308,7 +310,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 308 |
idx += 1
|
| 309 |
elif self.config.name == "preprocessed_bitmaps":
|
| 310 |
idx = 0
|
| 311 |
-
for label, file in files
|
| 312 |
with open(file, "rb") as f:
|
| 313 |
images = np.load(f)
|
| 314 |
for image in images:
|
|
@@ -319,7 +321,7 @@ class Quickdraw(datasets.GeneratorBasedBuilder):
|
|
| 319 |
idx += 1
|
| 320 |
else: # sketch_rnn, sketch_rnn_full
|
| 321 |
idx = 0
|
| 322 |
-
for label, file in files
|
| 323 |
with open(os.path.join(file, f"{split}.npy"), "rb") as f:
|
| 324 |
# read entire file since f.seek is not supported in the streaming mode
|
| 325 |
drawings = np.load(io.BytesIO(f.read()), encoding="latin1", allow_pickle=True)
|
|
|
|
| 246 |
files = dl_manager.download(
|
| 247 |
{name: url for name, url in zip(_NAMES, [base_url.format(name) for name in _NAMES])}
|
| 248 |
)
|
| 249 |
+
files = [(name, file) for name, file in files.items()]
|
| 250 |
return [
|
| 251 |
datasets.SplitGenerator(
|
| 252 |
name=datasets.Split.TRAIN,
|
|
|
|
| 260 |
files = dl_manager.download_and_extract(
|
| 261 |
{name: url for name, url in zip(_NAMES, [base_url.format(name) for name in _NAMES])}
|
| 262 |
)
|
| 263 |
+
files = [(name, file) for name, file in files.items()]
|
| 264 |
return [
|
| 265 |
datasets.SplitGenerator(
|
| 266 |
name=datasets.Split.TRAIN,
|
|
|
|
| 288 |
def _generate_examples(self, files, split):
|
| 289 |
if self.config.name == "raw":
|
| 290 |
idx = 0
|
| 291 |
+
for _, file in files:
|
| 292 |
with open(file, encoding="utf-8") as f:
|
| 293 |
for line in f:
|
| 294 |
example = json.loads(line)
|
|
|
|
| 298 |
idx += 1
|
| 299 |
elif self.config.name == "preprocessed_simplified_drawings":
|
| 300 |
idx = 0
|
| 301 |
+
for label, file in files:
|
| 302 |
with open(file, "rb") as f:
|
| 303 |
while True:
|
| 304 |
try:
|
|
|
|
| 310 |
idx += 1
|
| 311 |
elif self.config.name == "preprocessed_bitmaps":
|
| 312 |
idx = 0
|
| 313 |
+
for label, file in files:
|
| 314 |
with open(file, "rb") as f:
|
| 315 |
images = np.load(f)
|
| 316 |
for image in images:
|
|
|
|
| 321 |
idx += 1
|
| 322 |
else: # sketch_rnn, sketch_rnn_full
|
| 323 |
idx = 0
|
| 324 |
+
for label, file in files:
|
| 325 |
with open(os.path.join(file, f"{split}.npy"), "rb") as f:
|
| 326 |
# read entire file since f.seek is not supported in the streaming mode
|
| 327 |
drawings = np.load(io.BytesIO(f.read()), encoding="latin1", allow_pickle=True)
|