| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | """Dream!n character datasets""" |
| |
|
| | import datasets |
| | import json |
| | import urllib |
| |
|
| | _CITATION = """ |
| | """ |
| |
|
| | _DESCRIPTION = "Dream!n object datasets" |
| |
|
| |
|
| | _DATASET_URL = "https://huggingface.co/datasets/JAWCF/objects/resolve/main/images.tar.gz" |
| |
|
| | json_url = urllib.urlopen("https://huggingface.co/datasets/JAWCF/objects/resolve/main/objects.json") |
| | DICT_DESC = json.loads(json_url.read()) |
| |
|
| | class Objects(datasets.GeneratorBasedBuilder): |
| |
|
| | def _info(self): |
| | features = datasets.Features({ |
| | 'image': datasets.Image(), |
| | 'text': datasets.Value('string') |
| | }) |
| | return datasets.DatasetInfo( |
| | |
| | description=_DESCRIPTION, |
| | |
| | features=features, |
| | supervised_keys=None, |
| | |
| | homepage="", |
| | |
| | license="", |
| | |
| | citation=_CITATION, |
| | ) |
| |
|
| | def _split_generators(self, dl_manager): |
| | path = dl_manager.download(_DATASET_URL) |
| | image_iters = dl_manager.iter_archive(path) |
| | splits = [ |
| | datasets.SplitGenerator( |
| | name=datasets.Split.TRAIN, |
| | gen_kwargs={ |
| | "images": image_iters |
| | } |
| | ), |
| | ] |
| | return splits |
| |
|
| | def _generate_examples(self, images): |
| | """Yields examples.""" |
| | idx = 0 |
| | for filepath, image in images: |
| | yield idx, { |
| | "image": {"path": filepath, "bytes": image.read()}, |
| | "text" : DICT_DESC[filepath], |
| | } |
| | idx+=1 |