|
"""Cartoonset-10k Data Set""" |
|
|
|
|
|
import pickle |
|
|
|
import numpy as np |
|
import PIL.Image |
|
|
|
|
|
import datasets |
|
from datasets.tasks import ImageClassification |
|
|
|
|
|
_CITATION = """\ |
|
@TECHREPORT{Krizhevsky09learningmultiple, |
|
author = {Alex Krizhevsky}, |
|
title = {Learning multiple layers of features from tiny images}, |
|
institution = {}, |
|
year = {2009} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
The Cartoonset-10k dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images |
|
per class. There are 50000 training images and 10000 test images. |
|
""" |
|
|
|
_DATA_URLS = { |
|
"10k": "https://storage.cloud.google.com/cartoonset_public_files/cartoonset10k.tgz", |
|
"100k": "https://storage.cloud.google.com/cartoonset_public_files/cartoonset100k.tgz", |
|
} |
|
|
|
_NAMES = [] |
|
|
|
|
|
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-10k 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): |
|
self.config.name |
|
print("URL:", _DATA_URL) |
|
archive = dl_manager.download(_DATA_URL) |
|
|
|
print(archive) |
|
exit() |
|
|
|
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.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("FILES", files) |
|
|
|
path: str |
|
for path, file_obj in files: |
|
|
|
if path.endswith(".png"): |
|
image = PIL.Image.open(path) |
|
|
|
yield path, { |
|
"img": np.asarray(image), |
|
} |
|
|