fbanimehq / fbanimehq.py
skytnt's picture
Upload fbanimehq.py
2861545
raw
history blame
1.72 kB
import os
import datasets
import PIL
from datasets import DownloadManager, DatasetInfo
_DESCRIPTION = """\
FBAnimeHQ is a dataset with high-quality full-body anime girl images in a resolution of 1024 × 512.
"""
_HOMEPAGE = "https://huggingface.co/datasets/skytnt/fbanimehq"
_URL_BASE = "https://huggingface.co/datasets/skytnt/fbanimehq/resolve/main/data/"
_URLS = [
_URL_BASE + "fbanimehq-00.zip",
_URL_BASE + "fbanimehq-01.zip",
_URL_BASE + "fbanimehq-02.zip",
_URL_BASE + "fbanimehq-03.zip",
_URL_BASE + "fbanimehq-04.zip",
]
class FBAnimeHQ(datasets.GeneratorBasedBuilder):
def _info(self) -> DatasetInfo:
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"image": datasets.Image(),
}
),
supervised_keys=None,
homepage=_HOMEPAGE,
citation="",
)
def _split_generators(self, dl_manager: DownloadManager):
downloaded_files = dl_manager.download_and_extract(_URLS)
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files})]
def _generate_examples(self, filepath):
for path in filepath:
all_fnames = {os.path.relpath(os.path.join(root, fname), start=path)
for root, _dirs, files in os.walk(path) for fname in files}
image_fnames = sorted(fname for fname in all_fnames
if os.path.splitext(fname)[1].lower() in PIL.Image.EXTENSION)
for image_fname in image_fnames:
yield image_fname, {"image": os.path.join(path, image_fname)}