animelover commited on
Commit
a829da7
1 Parent(s): 43911d9

Update princess-connect-images.py

Browse files
Files changed (1) hide show
  1. princess-connect-images.py +26 -12
princess-connect-images.py CHANGED
@@ -13,25 +13,35 @@ 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
  ]
24
 
25
  def _info(self) -> DatasetInfo:
 
 
 
 
 
 
 
 
 
 
 
26
  return datasets.DatasetInfo(
27
  description=self.config.description,
28
- features=datasets.Features(
29
- {
30
- "image": datasets.Image(),
31
- "tags": datasets.Value("string"),
32
- "post_id": datasets.Value("int64"),
33
- }
34
- ),
35
  supervised_keys=None,
36
  citation="",
37
  )
@@ -60,10 +70,14 @@ 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 == "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}
 
 
 
67
 
68
 
69
- nsfw_tags = ["nude", "sex", "nipples", "pussy", "vaginal", "pubic_hair", "anus", "penis", "cum", "condom", "sex toy"]
 
 
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
+ datasets.BuilderConfig(
24
+ name="2-tags",
25
+ description="only tags of dataset",
26
+ ),
27
  ]
28
 
29
  def _info(self) -> DatasetInfo:
30
+ if self.config.name == "2-tags":
31
+ features = {
32
+ "tags": datasets.Value("string"),
33
+ "post_id": datasets.Value("int64")
34
+ }
35
+ else:
36
+ features = {
37
+ "image": datasets.Image(),
38
+ "tags": datasets.Value("string"),
39
+ "post_id": datasets.Value("int64")
40
+ }
41
  return datasets.DatasetInfo(
42
  description=self.config.description,
43
+
44
+ features=datasets.Features(features),
 
 
 
 
 
45
  supervised_keys=None,
46
  citation="",
47
  )
 
70
  tags_path = os.path.join(path, os.path.splitext(image_fname)[0] + ".txt")
71
  with open(tags_path, "r", encoding="utf-8") as f:
72
  tags = f.read()
73
+ if self.config.name == "0-sfw" and any(tag.strip() in nsfw_tags for tag in tags.split(",")):
74
  continue
75
  post_id = int(os.path.splitext(os.path.basename(image_fname))[0])
76
+ if self.config.name == "2-tags":
77
+ yield image_fname, {"tags": tags, "post_id": post_id}
78
+ else:
79
+ yield image_fname, {"image": image_path, "tags": tags, "post_id": post_id}
80
 
81
 
82
+ nsfw_tags = ["nude", "completely nude", "topless", "bottomless", "sex", "oral", "fellatio gesture", "tentacle sex",
83
+ "nipples", "pussy", "vaginal", "pubic hair", "anus", "ass focus", "penis", "cum", "condom", "sex toy"]