animelover commited on
Commit
d4cb4fb
1 Parent(s): d1e069a

Update danbooru2022.py

Browse files
Files changed (1) hide show
  1. danbooru2022.py +23 -9
danbooru2022.py CHANGED
@@ -20,18 +20,28 @@ class DanbooruDataset(datasets.GeneratorBasedBuilder):
20
  name="1-full",
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
  )
@@ -63,7 +73,11 @@ class DanbooruDataset(datasets.GeneratorBasedBuilder):
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}
 
 
 
67
 
68
 
69
- nsfw_tags = ["nude", "completely nude", "topless", "bottomless", "sex", "oral", "fellatio gesture", "tentacle sex", "nipples", "pussy", "vaginal", "pubic hair", "anus", "ass focus", "penis", "cum", "condom", "sex toy"]
 
 
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
  )
 
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"]