Yassine
commited on
Commit
•
53a7514
1
Parent(s):
2b625b3
only file paths for now?
Browse files- commavq.py +11 -13
commavq.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import datasets
|
2 |
-
|
|
|
3 |
import numpy as np
|
4 |
|
5 |
SHARD_SIZE = 2500
|
6 |
NUM_SHARDS = 40
|
7 |
_URLS = [
|
8 |
-
f'https://huggingface.co/datasets/commaai/commavq/
|
9 |
]
|
10 |
|
11 |
_DESCRIPTION = """\
|
@@ -13,24 +14,21 @@ TODO
|
|
13 |
"""
|
14 |
|
15 |
class CommaVQ(datasets.GeneratorBasedBuilder):
|
16 |
-
def _info(self):
|
17 |
|
|
|
18 |
return datasets.DatasetInfo(
|
19 |
-
# This is the description that will appear on the datasets page.
|
20 |
description=_DESCRIPTION,
|
|
|
|
|
|
|
21 |
)
|
22 |
|
23 |
def _split_generators(self, dl_manager):
|
24 |
"""Returns SplitGenerators."""
|
25 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
26 |
-
|
27 |
-
return [
|
28 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": x}) for x in downloaded_files
|
29 |
-
]
|
30 |
|
31 |
def _generate_examples(self, filepaths):
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
for name in input_zip.namelist():
|
36 |
-
yield name, {'tokens': input_zip.read(name)}
|
|
|
1 |
import datasets
|
2 |
+
import glob
|
3 |
+
import os
|
4 |
import numpy as np
|
5 |
|
6 |
SHARD_SIZE = 2500
|
7 |
NUM_SHARDS = 40
|
8 |
_URLS = [
|
9 |
+
f'https://huggingface.co/datasets/commaai/commavq/resolve/main/data_{i*SHARD_SIZE}_to_{(i+1)*SHARD_SIZE}.zip' for i in range(NUM_SHARDS)
|
10 |
]
|
11 |
|
12 |
_DESCRIPTION = """\
|
|
|
14 |
"""
|
15 |
|
16 |
class CommaVQ(datasets.GeneratorBasedBuilder):
|
|
|
17 |
|
18 |
+
def _info(self):
|
19 |
return datasets.DatasetInfo(
|
|
|
20 |
description=_DESCRIPTION,
|
21 |
+
features=datasets.Features(
|
22 |
+
{"path": datasets.Value("string")}
|
23 |
+
)
|
24 |
)
|
25 |
|
26 |
def _split_generators(self, dl_manager):
|
27 |
"""Returns SplitGenerators."""
|
28 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
29 |
+
return [datasets.SplitGenerator(name=str(i), gen_kwargs={"filepaths": x}) for i, x in enumerate(downloaded_files)]
|
|
|
|
|
|
|
30 |
|
31 |
def _generate_examples(self, filepaths):
|
32 |
+
for path in glob.glob(f'{filepaths}/*.npy'):
|
33 |
+
name = os.path.basename(path)
|
34 |
+
yield name, {'path': path}
|
|
|
|