"""Cartoonset-10k Data Set""" import pickle import numpy as np import PIL.Image 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(), } ), supervised_keys=("img",), 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 for path, file_obj in files: if path.endswith(".png"): image = PIL.Image.open(file_obj) yield path, { "img": image, }