File size: 3,237 Bytes
8f5e012 30797c9 8f5e012 5679ebe 8f5e012 5679ebe 8f5e012 10344b3 9467ecf 10344b3 8f5e012 10344b3 8f5e012 10344b3 8f5e012 10344b3 5679ebe 10344b3 8f5e012 10344b3 8f5e012 30797c9 8f5e012 ad96d5b 8f5e012 10344b3 30797c9 f105ee9 9467ecf 8f5e012 30797c9 8f5e012 30797c9 8f5e012 30797c9 8f5e012 |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
"""Cartoonset-10k Data Set"""
import pickle
import numpy as np
import PIL.Image
import tarfile
import datasets
from datasets.tasks import ImageClassification
_CITATION = r"""
@article{DBLP:journals/corr/abs-1711-05139,
author = {Amelie Royer and
Konstantinos Bousmalis and
Stephan Gouws and
Fred Bertsch and
Inbar Mosseri and
Forrester Cole and
Kevin Murphy},
title = {{XGAN:} Unsupervised Image-to-Image Translation for many-to-many Mappings},
journal = {CoRR},
volume = {abs/1711.05139},
year = {2017},
url = {http://arxiv.org/abs/1711.05139},
eprinttype = {arXiv},
eprint = {1711.05139},
timestamp = {Mon, 13 Aug 2018 16:47:38 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-1711-05139.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
"""
_DESCRIPTION = """\
Cartoon Set is a collection of random, 2D cartoon avatar images. The cartoons vary in 10 artwork
categories, 4 color categories, and 4 proportion categories, with a total of ~1013 possible
combinations. We provide sets of 10k and 100k randomly chosen cartoons and labeled attributes.
"""
_DATA_URLS = {
"10k": "https://huggingface.co/datasets/cgarciae/cartoonset/resolve/1.0.0/data/cartoonset10k.tgz",
"100k": "https://huggingface.co/datasets/cgarciae/cartoonset/resolve/1.0.0/data/cartoonset100k.tgz",
}
class Cartoonset(datasets.GeneratorBasedBuilder):
"""Cartoonset-10k Data Set"""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="10k",
version=datasets.Version("1.0.0", ""),
description="Loads the Cartoonset-10k Data Set",
),
datasets.BuilderConfig(
name="100k",
version=datasets.Version("1.0.0", ""),
description="Loads the Cartoonset-100k Data Set",
),
]
DEFAULT_CONFIG_NAME = "10k"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
# "img": datasets.Image(),
"img_bytes": datasets.Value("binary"),
}
),
supervised_keys=("img_bytes",),
homepage="https://www.cs.toronto.edu/~kriz/cifar.html",
citation=_CITATION,
)
def _split_generators(self, dl_manager: datasets.DownloadManager):
url = _DATA_URLS[self.config.name]
archive = dl_manager.download(url)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"files": dl_manager.iter_archive(archive),
"split": "train",
},
),
]
def _generate_examples(self, files, split):
"""This function returns the examples in the raw (text) form."""
path: str
file_obj: tarfile.ExFileObject
for path, file_obj in files:
if path.endswith(".png"):
image = file_obj.read()
yield path, {
"img_bytes": image,
}
|