Yassine commited on
Commit
2b625b3
1 Parent(s): 583e9a0

dataset builder?

Browse files
Files changed (1) hide show
  1. commavq.py +36 -0
commavq.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ from zipfile import ZipFile
3
+ import numpy as np
4
+
5
+ SHARD_SIZE = 2500
6
+ NUM_SHARDS = 40
7
+ _URLS = [
8
+ f'https://huggingface.co/datasets/commaai/commavq/blob/main/data_{i*SHARD_SIZE}_to_{(i+1)*SHARD_SIZE}.zip' for i in range(NUM_SHARDS)
9
+ ]
10
+
11
+ _DESCRIPTION = """\
12
+ 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
+ """Yields examples."""
33
+ for filepath in filepaths:
34
+ input_zip = ZipFile(filepath)
35
+ for name in input_zip.namelist():
36
+ yield name, {'tokens': input_zip.read(name)}