Update fbanimehq.py
Browse files- fbanimehq.py +21 -7
fbanimehq.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
import datasets
|
3 |
-
import PIL
|
4 |
from datasets import DownloadManager, DatasetInfo
|
5 |
|
6 |
_DESCRIPTION = """\
|
@@ -8,16 +7,31 @@ FBAnimeHQ is a dataset with high-quality full-body anime girl images in a resolu
|
|
8 |
"""
|
9 |
_HOMEPAGE = "https://huggingface.co/datasets/skytnt/fbanimehq"
|
10 |
_URL_BASE = "https://huggingface.co/datasets/skytnt/fbanimehq/resolve/main/data/"
|
11 |
-
|
|
|
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(
|
@@ -33,14 +47,14 @@ class FBAnimeHQ(datasets.GeneratorBasedBuilder):
|
|
33 |
)
|
34 |
|
35 |
def _split_generators(self, dl_manager: DownloadManager):
|
36 |
-
|
37 |
-
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"
|
38 |
|
39 |
-
def _generate_examples(self,
|
40 |
-
for path in
|
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
|
45 |
for image_fname in image_fnames:
|
46 |
yield image_fname, {"image": os.path.join(path, image_fname)}
|
|
|
1 |
import os
|
2 |
import datasets
|
|
|
3 |
from datasets import DownloadManager, DatasetInfo
|
4 |
|
5 |
_DESCRIPTION = """\
|
|
|
7 |
"""
|
8 |
_HOMEPAGE = "https://huggingface.co/datasets/skytnt/fbanimehq"
|
9 |
_URL_BASE = "https://huggingface.co/datasets/skytnt/fbanimehq/resolve/main/data/"
|
10 |
+
_EXTENSION = [".png", ".jpg"]
|
11 |
+
_URLS_HQ = [
|
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 |
+
_URLS_SMALL = [
|
19 |
+
_URL_BASE + "fbanimesmall.zip",
|
20 |
+
]
|
21 |
+
|
22 |
+
|
23 |
+
class FBAnimeHQConfig(datasets.BuilderConfig):
|
24 |
+
|
25 |
+
def __init__(self, urls, **kwargs):
|
26 |
+
super(FBAnimeHQConfig, self).__init__(**kwargs)
|
27 |
+
self.urls = urls
|
28 |
|
29 |
|
30 |
class FBAnimeHQ(datasets.GeneratorBasedBuilder):
|
31 |
+
BUILDER_CONFIGS = [
|
32 |
+
FBAnimeHQConfig(name="hq", urls=_URLS_HQ),
|
33 |
+
FBAnimeHQConfig(name="small", urls=_URLS_SMALL)
|
34 |
+
]
|
35 |
|
36 |
def _info(self) -> DatasetInfo:
|
37 |
return datasets.DatasetInfo(
|
|
|
47 |
)
|
48 |
|
49 |
def _split_generators(self, dl_manager: DownloadManager):
|
50 |
+
dirs = dl_manager.download_and_extract(self.config.urls)
|
51 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"dirs": dirs})]
|
52 |
|
53 |
+
def _generate_examples(self, dirs):
|
54 |
+
for path in dirs:
|
55 |
all_fnames = {os.path.relpath(os.path.join(root, fname), start=path)
|
56 |
for root, _dirs, files in os.walk(path) for fname in files}
|
57 |
image_fnames = sorted(fname for fname in all_fnames
|
58 |
+
if os.path.splitext(fname)[1].lower() in _EXTENSION)
|
59 |
for image_fname in image_fnames:
|
60 |
yield image_fname, {"image": os.path.join(path, image_fname)}
|