animelover
commited on
Commit
•
9e41f27
1
Parent(s):
147c0d5
Update danbooru2022.py
Browse files- danbooru2022.py +4 -3
danbooru2022.py
CHANGED
@@ -11,12 +11,13 @@ _REVISION = "main"
|
|
11 |
|
12 |
class DanbooruDataset(datasets.GeneratorBasedBuilder):
|
13 |
BUILDER_CONFIGS = [
|
|
|
14 |
datasets.BuilderConfig(
|
15 |
-
name="
|
16 |
description="sfw subset",
|
17 |
),
|
18 |
datasets.BuilderConfig(
|
19 |
-
name="
|
20 |
description="full dataset",
|
21 |
),
|
22 |
]
|
@@ -59,7 +60,7 @@ class DanbooruDataset(datasets.GeneratorBasedBuilder):
|
|
59 |
tags_path = os.path.join(path, os.path.splitext(image_fname)[0] + ".txt")
|
60 |
with open(tags_path, "r", encoding="utf-8") as f:
|
61 |
tags = f.read()
|
62 |
-
if self.config.name == "
|
63 |
continue
|
64 |
post_id = int(os.path.splitext(os.path.basename(image_fname))[0])
|
65 |
yield image_fname, {"image": image_path, "tags": tags, "post_id": post_id}
|
|
|
11 |
|
12 |
class DanbooruDataset(datasets.GeneratorBasedBuilder):
|
13 |
BUILDER_CONFIGS = [
|
14 |
+
# add number before name for sorting
|
15 |
datasets.BuilderConfig(
|
16 |
+
name="0sfw",
|
17 |
description="sfw subset",
|
18 |
),
|
19 |
datasets.BuilderConfig(
|
20 |
+
name="1full",
|
21 |
description="full dataset",
|
22 |
),
|
23 |
]
|
|
|
60 |
tags_path = os.path.join(path, os.path.splitext(image_fname)[0] + ".txt")
|
61 |
with open(tags_path, "r", encoding="utf-8") as f:
|
62 |
tags = f.read()
|
63 |
+
if self.config.name == "0sfw" and any(tag.strip() in nsfw_tags for tag in tags.split(",")):
|
64 |
continue
|
65 |
post_id = int(os.path.splitext(os.path.basename(image_fname))[0])
|
66 |
yield image_fname, {"image": image_path, "tags": tags, "post_id": post_id}
|