Datasets:
import: copybara import of the project
Browse filesProject import generated by Copybara.
GitOrigin-RevId: bc26ddfdecf9cfa16a123c254adfe31b2111b4ee
- .gitattributes +2 -0
- coda.py +90 -0
.gitattributes
CHANGED
|
@@ -25,3 +25,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.csv filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.jsonl filter=lfs diff=lfs merge=lfs -text
|
coda.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Cory Paik. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
# ==============================================================================
|
| 15 |
+
""" The Color Dataset (CoDa)
|
| 16 |
+
|
| 17 |
+
TODO
|
| 18 |
+
"""
|
| 19 |
+
import json
|
| 20 |
+
|
| 21 |
+
import datasets
|
| 22 |
+
|
| 23 |
+
_CITATION = """\
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
_DESCRIPTION = """\
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
_HOMEPAGE = 'https://github.com/nala-cub/coda'
|
| 30 |
+
_LICENSE = 'Apache 2.0'
|
| 31 |
+
|
| 32 |
+
_URL = 'https://huggingface.co/datasets/corypaik/coda/resolve/main/data'
|
| 33 |
+
|
| 34 |
+
_URLs = {
|
| 35 |
+
'default': {
|
| 36 |
+
'train': f'{_URL}/default_train.jsonl',
|
| 37 |
+
'validation': f'{_URL}/default_validation.jsonl',
|
| 38 |
+
'test': f'{_URL}/default_test.jsonl',
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class Coda(datasets.GeneratorBasedBuilder):
|
| 44 |
+
|
| 45 |
+
VERSION = datasets.Version('1.0.0')
|
| 46 |
+
|
| 47 |
+
# TODO(corypaik): add object and annotation configs.
|
| 48 |
+
|
| 49 |
+
def _info(self):
|
| 50 |
+
features = datasets.Features({
|
| 51 |
+
'class_id':
|
| 52 |
+
datasets.Value('string'),
|
| 53 |
+
'display_name':
|
| 54 |
+
datasets.Value('string'),
|
| 55 |
+
'ngram':
|
| 56 |
+
datasets.Value('string'),
|
| 57 |
+
'label':
|
| 58 |
+
datasets.Sequence(datasets.Value('float')),
|
| 59 |
+
'object_group':
|
| 60 |
+
datasets.ClassLabel(names=('Single', 'Multi', 'Any')),
|
| 61 |
+
'text':
|
| 62 |
+
datasets.Value('string'),
|
| 63 |
+
'template_group':
|
| 64 |
+
datasets.ClassLabel(names=('clip-imagenet', 'text-masked')),
|
| 65 |
+
'template_idx':
|
| 66 |
+
datasets.Value('int32')
|
| 67 |
+
})
|
| 68 |
+
return datasets.DatasetInfo(description=_DESCRIPTION,
|
| 69 |
+
features=features,
|
| 70 |
+
supervised_keys=None,
|
| 71 |
+
homepage=_HOMEPAGE,
|
| 72 |
+
license=_LICENSE,
|
| 73 |
+
citation=_CITATION)
|
| 74 |
+
|
| 75 |
+
def _split_generators(self, dl_manager):
|
| 76 |
+
""" Returns SplitGenerators."""
|
| 77 |
+
files = dl_manager.download_and_extract(_URLs[self.config.name])
|
| 78 |
+
return [
|
| 79 |
+
datasets.SplitGenerator(datasets.Split.TRAIN,
|
| 80 |
+
gen_kwargs={'path': files['train']}),
|
| 81 |
+
datasets.SplitGenerator(datasets.Split.VALIDATION,
|
| 82 |
+
gen_kwargs={'path': files['validation']}),
|
| 83 |
+
datasets.SplitGenerator(datasets.Split.TEST,
|
| 84 |
+
gen_kwargs={'path': files['test']}),
|
| 85 |
+
]
|
| 86 |
+
|
| 87 |
+
def _generate_examples(self, path):
|
| 88 |
+
with open(path, 'r') as f:
|
| 89 |
+
for _id, line in enumerate(f.readlines()):
|
| 90 |
+
yield _id, json.loads(line)
|