skytnt commited on
Commit
2861545
1 Parent(s): 08da737

Upload fbanimehq.py

Browse files
Files changed (1) hide show
  1. fbanimehq.py +46 -0
fbanimehq.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import datasets
3
+ import PIL
4
+ from datasets import DownloadManager, DatasetInfo
5
+
6
+ _DESCRIPTION = """\
7
+ FBAnimeHQ is a dataset with high-quality full-body anime girl images in a resolution of 1024 × 512.
8
+ """
9
+ _HOMEPAGE = "https://huggingface.co/datasets/skytnt/fbanimehq"
10
+ _URL_BASE = "https://huggingface.co/datasets/skytnt/fbanimehq/resolve/main/data/"
11
+ _URLS = [
12
+ _URL_BASE + "fbanimehq-00.zip",
13
+ _URL_BASE + "fbanimehq-01.zip",
14
+ _URL_BASE + "fbanimehq-02.zip",
15
+ _URL_BASE + "fbanimehq-03.zip",
16
+ _URL_BASE + "fbanimehq-04.zip",
17
+ ]
18
+
19
+
20
+ class FBAnimeHQ(datasets.GeneratorBasedBuilder):
21
+
22
+ def _info(self) -> DatasetInfo:
23
+ return datasets.DatasetInfo(
24
+ description=_DESCRIPTION,
25
+ features=datasets.Features(
26
+ {
27
+ "image": datasets.Image(),
28
+ }
29
+ ),
30
+ supervised_keys=None,
31
+ homepage=_HOMEPAGE,
32
+ citation="",
33
+ )
34
+
35
+ def _split_generators(self, dl_manager: DownloadManager):
36
+ downloaded_files = dl_manager.download_and_extract(_URLS)
37
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files})]
38
+
39
+ def _generate_examples(self, filepath):
40
+ for path in filepath:
41
+ all_fnames = {os.path.relpath(os.path.join(root, fname), start=path)
42
+ for root, _dirs, files in os.walk(path) for fname in files}
43
+ image_fnames = sorted(fname for fname in all_fnames
44
+ if os.path.splitext(fname)[1].lower() in PIL.Image.EXTENSION)
45
+ for image_fname in image_fnames:
46
+ yield image_fname, {"image": os.path.join(path, image_fname)}