File size: 992 Bytes
2b625b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import datasets
from zipfile import ZipFile
import numpy as np
SHARD_SIZE = 2500
NUM_SHARDS = 40
_URLS = [
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)
]
_DESCRIPTION = """\
TODO
"""
class CommaVQ(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": x}) for x in downloaded_files
]
def _generate_examples(self, filepaths):
"""Yields examples."""
for filepath in filepaths:
input_zip = ZipFile(filepath)
for name in input_zip.namelist():
yield name, {'tokens': input_zip.read(name)}
|