commavq / commavq.py
Yassine
dataset builder?
2b625b3
raw
history blame
992 Bytes
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)}