|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" The Color Dataset (CoDa) |
|
|
|
TODO |
|
""" |
|
import json |
|
|
|
import datasets |
|
|
|
_CITATION = """\ |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
""" |
|
|
|
_HOMEPAGE = 'https://github.com/nala-cub/coda' |
|
_LICENSE = 'Apache 2.0' |
|
|
|
_URL = 'https://huggingface.co/datasets/corypaik/coda/resolve/main/data' |
|
|
|
_URLs = { |
|
'default': { |
|
'train': f'{_URL}/default_train.jsonl', |
|
'validation': f'{_URL}/default_validation.jsonl', |
|
'test': f'{_URL}/default_test.jsonl', |
|
} |
|
} |
|
|
|
|
|
class Coda(datasets.GeneratorBasedBuilder): |
|
|
|
VERSION = datasets.Version('1.0.0') |
|
|
|
|
|
|
|
def _info(self): |
|
features = datasets.Features({ |
|
'class_id': |
|
datasets.Value('string'), |
|
'display_name': |
|
datasets.Value('string'), |
|
'ngram': |
|
datasets.Value('string'), |
|
'label': |
|
datasets.Sequence(datasets.Value('float')), |
|
'object_group': |
|
datasets.ClassLabel(names=('Single', 'Multi', 'Any')), |
|
'text': |
|
datasets.Value('string'), |
|
'template_group': |
|
datasets.ClassLabel(names=('clip-imagenet', 'text-masked')), |
|
'template_idx': |
|
datasets.Value('int32') |
|
}) |
|
return datasets.DatasetInfo(description=_DESCRIPTION, |
|
features=features, |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION) |
|
|
|
def _split_generators(self, dl_manager): |
|
""" Returns SplitGenerators.""" |
|
files = dl_manager.download_and_extract(_URLs[self.config.name]) |
|
return [ |
|
datasets.SplitGenerator(datasets.Split.TRAIN, |
|
gen_kwargs={'path': files['train']}), |
|
datasets.SplitGenerator(datasets.Split.VALIDATION, |
|
gen_kwargs={'path': files['validation']}), |
|
datasets.SplitGenerator(datasets.Split.TEST, |
|
gen_kwargs={'path': files['test']}), |
|
] |
|
|
|
def _generate_examples(self, path): |
|
with open(path, 'r') as f: |
|
for _id, line in enumerate(f.readlines()): |
|
yield _id, json.loads(line) |
|
|