animelover
commited on
Commit
•
8d340f0
1
Parent(s):
1c2090d
Update danbooru2022.py
Browse files- danbooru2022.py +3 -3
danbooru2022.py
CHANGED
@@ -13,11 +13,11 @@ class DanbooruDataset(datasets.GeneratorBasedBuilder):
|
|
13 |
BUILDER_CONFIGS = [
|
14 |
# add number before name for sorting
|
15 |
datasets.BuilderConfig(
|
16 |
-
name="
|
17 |
description="sfw subset",
|
18 |
),
|
19 |
datasets.BuilderConfig(
|
20 |
-
name="
|
21 |
description="full dataset",
|
22 |
),
|
23 |
]
|
@@ -60,7 +60,7 @@ class DanbooruDataset(datasets.GeneratorBasedBuilder):
|
|
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 == "
|
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}
|
|
|
13 |
BUILDER_CONFIGS = [
|
14 |
# add number before name for sorting
|
15 |
datasets.BuilderConfig(
|
16 |
+
name="0-sfw",
|
17 |
description="sfw subset",
|
18 |
),
|
19 |
datasets.BuilderConfig(
|
20 |
+
name="1-full",
|
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 == "0-sfw" 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}
|