avans06 commited on
Commit
b2d4dc0
·
1 Parent(s): 624fa8c

Add Display of Classification Results

Browse files

When executing the WaifuDiffusion Tagger on images, the generated tags will now be analyzed and categorized into corresponding groups. This program has established the following groups:

Appearance Status,
Action Pose,
Headwear,
Handwear,
One-Piece Outfit,
Upper Body Clothing,
Lower Body Clothing,
Footwear,
Other Accessories,
Facial Expression,
Head,
Hands,
Upper Body,
Lower Body,
Creature,
Plant,
Food,
Beverage,
Music,
Weapons & Equipment,
Vehicles,
Buildings,
Indoor,
Outdoor,
Objects,
Character Design,
Composition,
Season,
Background,
Patterns,
Censorship,
Others

Files changed (4) hide show
  1. README.md +1 -1
  2. app.py +21 -9
  3. classifyTags.py +149 -0
  4. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 💬
4
  colorFrom: purple
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 5.12.0
8
  app_file: app.py
9
  pinned: true
10
  ---
 
4
  colorFrom: purple
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 5.14.0
8
  app_file: app.py
9
  pinned: true
10
  ---
app.py CHANGED
@@ -13,12 +13,16 @@ import zipfile
13
  import re
14
  from datetime import datetime
15
  from collections import defaultdict
 
16
 
17
  TITLE = "WaifuDiffusion Tagger multiple images"
18
  DESCRIPTION = """
19
- Demo for the WaifuDiffusion tagger models
20
-
21
  Example image by [ほし☆☆☆](https://www.pixiv.net/en/users/43565085)
 
 
 
 
22
  """
23
 
24
  # Dataset v3 series of models:
@@ -434,7 +438,11 @@ class Predictor:
434
  if append_list:
435
  sorted_general_list = [item for item in sorted_general_list if item not in append_list]
436
 
437
- sorted_general_strings = ", ".join((character_list if characters_merge_enabled else []) + prepend_list + sorted_general_list + append_list).replace("(", "\(").replace(")", "\)")
 
 
 
 
438
 
439
  if llama3_reorganize_model_repo:
440
  print(f"Starting reorganize with llama3...")
@@ -447,7 +455,7 @@ class Predictor:
447
  txt_file = self.create_file(sorted_general_strings, output_dir, image_name + ".txt")
448
  txt_infos.append({"path":txt_file, "name": image_name + ".txt"})
449
 
450
- tag_results[image_path] = { "strings": sorted_general_strings, "rating": rating, "character_res": character_res, "general_res": general_res }
451
 
452
  except Exception as e:
453
  print(traceback.format_exc())
@@ -469,17 +477,17 @@ class Predictor:
469
 
470
  print("Predict is complete.")
471
 
472
- return download, sorted_general_strings, rating, character_res, general_res, tag_results
473
 
474
  def get_selection_from_gallery(gallery: list, tag_results: dict, selected_state: gr.SelectData):
475
  if not selected_state:
476
  return selected_state
477
 
478
- tag_result = { "strings": "", "rating": "", "character_res": "", "general_res": "" }
479
  if selected_state.value["image"]["path"] in tag_results:
480
  tag_result = tag_results[selected_state.value["image"]["path"]]
481
 
482
- return (selected_state.value["image"]["path"], selected_state.value["caption"]), tag_result["strings"], tag_result["rating"], tag_result["character_res"], tag_result["general_res"]
483
 
484
  def append_gallery(gallery: list, image: str):
485
  if gallery is None:
@@ -626,16 +634,20 @@ def main():
626
  with gr.Column(variant="panel"):
627
  download_file = gr.File(label="Output (Download)")
628
  sorted_general_strings = gr.Textbox(label="Output (string)", show_label=True, show_copy_button=True)
 
629
  rating = gr.Label(label="Rating")
630
  character_res = gr.Label(label="Output (characters)")
631
  general_res = gr.Label(label="Output (tags)")
 
632
  clear.add(
633
  [
634
  download_file,
635
  sorted_general_strings,
 
636
  rating,
637
  character_res,
638
  general_res,
 
639
  ]
640
  )
641
 
@@ -646,7 +658,7 @@ def main():
646
  upload_button.upload(extend_gallery, inputs=[gallery, upload_button], outputs=gallery)
647
  # Event to update the selected image when an image is clicked in the gallery
648
  selected_image = gr.Textbox(label="Selected Image", visible=False)
649
- gallery.select(get_selection_from_gallery, inputs=[gallery, tag_results], outputs=[selected_image, sorted_general_strings, rating, character_res, general_res])
650
  # Event to remove a selected image from the gallery
651
  remove_button.click(remove_image_from_gallery, inputs=[gallery, selected_image], outputs=gallery)
652
 
@@ -665,7 +677,7 @@ def main():
665
  additional_tags_append,
666
  tag_results,
667
  ],
668
- outputs=[download_file, sorted_general_strings, rating, character_res, general_res, tag_results,],
669
  )
670
 
671
  gr.Examples(
 
13
  import re
14
  from datetime import datetime
15
  from collections import defaultdict
16
+ from classifyTags import classify_tags
17
 
18
  TITLE = "WaifuDiffusion Tagger multiple images"
19
  DESCRIPTION = """
20
+ Demo for the WaifuDiffusion tagger models
 
21
  Example image by [ほし☆☆☆](https://www.pixiv.net/en/users/43565085)
22
+
23
+ Features of This Modified Version:
24
+ - Supports batch processing of multiple images
25
+ - Displays tag results in categorized groups: the generated tags will now be analyzed and categorized into corresponding groups.
26
  """
27
 
28
  # Dataset v3 series of models:
 
438
  if append_list:
439
  sorted_general_list = [item for item in sorted_general_list if item not in append_list]
440
 
441
+ sorted_general_list = prepend_list + sorted_general_list + append_list
442
+
443
+ sorted_general_strings = ", ".join((character_list if characters_merge_enabled else []) + sorted_general_list).replace("(", "\(").replace(")", "\)")
444
+
445
+ classified_tags, unclassified_tags = classify_tags(sorted_general_list)
446
 
447
  if llama3_reorganize_model_repo:
448
  print(f"Starting reorganize with llama3...")
 
455
  txt_file = self.create_file(sorted_general_strings, output_dir, image_name + ".txt")
456
  txt_infos.append({"path":txt_file, "name": image_name + ".txt"})
457
 
458
+ tag_results[image_path] = { "strings": sorted_general_strings, "classified_tags": classified_tags, "rating": rating, "character_res": character_res, "general_res": general_res, "unclassified_tags": unclassified_tags }
459
 
460
  except Exception as e:
461
  print(traceback.format_exc())
 
477
 
478
  print("Predict is complete.")
479
 
480
+ return download, sorted_general_strings, classified_tags, rating, character_res, general_res, unclassified_tags, tag_results
481
 
482
  def get_selection_from_gallery(gallery: list, tag_results: dict, selected_state: gr.SelectData):
483
  if not selected_state:
484
  return selected_state
485
 
486
+ tag_result = { "strings": "", "classified_tags": "", "rating": "", "character_res": "", "general_res": "", "unclassified_tags": "" }
487
  if selected_state.value["image"]["path"] in tag_results:
488
  tag_result = tag_results[selected_state.value["image"]["path"]]
489
 
490
+ return (selected_state.value["image"]["path"], selected_state.value["caption"]), tag_result["strings"], tag_result["classified_tags"], tag_result["rating"], tag_result["character_res"], tag_result["general_res"], tag_result["unclassified_tags"]
491
 
492
  def append_gallery(gallery: list, image: str):
493
  if gallery is None:
 
634
  with gr.Column(variant="panel"):
635
  download_file = gr.File(label="Output (Download)")
636
  sorted_general_strings = gr.Textbox(label="Output (string)", show_label=True, show_copy_button=True)
637
+ categorized = gr.JSON(label="Categorized (tags)")
638
  rating = gr.Label(label="Rating")
639
  character_res = gr.Label(label="Output (characters)")
640
  general_res = gr.Label(label="Output (tags)")
641
+ unclassified = gr.JSON(label="Unclassified (tags)")
642
  clear.add(
643
  [
644
  download_file,
645
  sorted_general_strings,
646
+ categorized,
647
  rating,
648
  character_res,
649
  general_res,
650
+ unclassified,
651
  ]
652
  )
653
 
 
658
  upload_button.upload(extend_gallery, inputs=[gallery, upload_button], outputs=gallery)
659
  # Event to update the selected image when an image is clicked in the gallery
660
  selected_image = gr.Textbox(label="Selected Image", visible=False)
661
+ gallery.select(get_selection_from_gallery, inputs=[gallery, tag_results], outputs=[selected_image, sorted_general_strings, categorized, rating, character_res, general_res, unclassified])
662
  # Event to remove a selected image from the gallery
663
  remove_button.click(remove_image_from_gallery, inputs=[gallery, selected_image], outputs=gallery)
664
 
 
677
  additional_tags_append,
678
  tag_results,
679
  ],
680
+ outputs=[download_file, sorted_general_strings, categorized, rating, character_res, general_res, unclassified, tag_results,],
681
  )
682
 
683
  gr.Examples(
classifyTags.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict
2
+
3
+
4
+ def classify_tags (tags: list[str], local_test: bool = False):
5
+ # Dictionary for automatic classification
6
+ classified_tags: defaultdict[str, str] = defaultdict(list)
7
+ fuzzy_match_tags: defaultdict[str, str] = defaultdict(list)
8
+ fuzzy_match_keylen = 0
9
+ fuzzy_match_category = ""
10
+ unclassified_tags: list[str] = []
11
+
12
+
13
+ # Logic for automatic grouping
14
+ for tag in tags:
15
+ classified = False
16
+ tag_new = tag.replace(" ", "_").replace("-", "_").replace("\\(", "(").replace("\\)", ")") # Replace spaces in source tags with underscores \"
17
+
18
+ keyword = ""
19
+ category = ""
20
+ if tag_new in reversed_categories:
21
+ category = reversed_categories[tag_new]
22
+ classified = True
23
+ else:
24
+ tag_parts = tag_new.split("_") # Split tags by "_" to ensure keyword matching is based on whole words
25
+ for keyword, category in reversed_categories.items():
26
+ keyword = keyword.replace("-", "_").strip("_")
27
+ verify = tag_new.replace(keyword, "")
28
+ # Check if the tag contains the keyword
29
+ if (tag_new == keyword or tag_new.lstrip("0123456789") == keyword or (keyword in tag_new and (verify.startswith("_") or verify.endswith("_")))):
30
+ classified = True
31
+ elif any(tag_part == keyword for tag_part in tag_parts):
32
+ classified = True
33
+ elif local_test and keyword in tag_new and len(keyword) > fuzzy_match_keylen:
34
+ fuzzy_match_keylen = len(keyword)
35
+ fuzzy_match_category = category
36
+ if classified:
37
+ break
38
+
39
+ if classified and tag not in classified_tags[category]: # Avoid duplicates
40
+ classified_tags[category].append(tag)
41
+
42
+ if not classified and fuzzy_match_keylen > 0 and tag not in fuzzy_match_tags[fuzzy_match_category]:
43
+ classified = True
44
+ fuzzy_match_tags[fuzzy_match_category].append(tag)
45
+ fuzzy_match_keylen = 0
46
+ fuzzy_match_category = ""
47
+
48
+ if not classified and tag not in unclassified_tags:
49
+ unclassified_tags.append(tag) # Unclassified tags
50
+
51
+ if local_test:
52
+ # Output the grouping result
53
+ for category, tags in classified_tags.items():
54
+ print(f"{category}:")
55
+ print(", ".join(tags))
56
+ print()
57
+
58
+ print()
59
+ print("Fuzzy match:")
60
+ for category, tags in fuzzy_match_tags.items():
61
+ print(f"{category}:")
62
+ print(", ".join(tags))
63
+ print()
64
+ print()
65
+
66
+ if len(unclassified_tags) > 0:
67
+ print(f"\nUnclassified tags: {len(unclassified_tags)}")
68
+ print(f"{unclassified_tags[:200]}") # Display some unclassified tags
69
+
70
+ return classified_tags, unclassified_tags
71
+
72
+ # Define grouping rules (categories and keywords)
73
+ categories = {
74
+ "explicit" : ["sex", "69", "paizuri", "cum", "precum", "areola_slip", "hetero", "erection", "oral", "fellatio", "yaoi", "ejaculation", "ejaculating", "masturbation", "handjob", "bulge", "rape", "doggystyle", "threesome", "missionary", "object_insertion", "nipple", "nipples", "pussy", "anus", "penis", "groin", "testicles", "testicle", "anal", "cameltoe", "areolae", "dildo", "clitoris", "top-down_bottom-up", "gag", "groping", "gagged", "gangbang", "orgasm", "femdom", "incest", "bukkake", "breast_out", "vaginal", "vagina", "public_indecency", "breast_sucking", "folded", "cunnilingus", "foreskin", "bestiality", "footjob", "uterus", "flaccid", "defloration", "butt_plug", "cowgirl_position", "reverse_cowgirl_position", "squatting_cowgirl_position", "reverse_upright_straddle", "irrumatio", "deepthroat", "pokephilia", "gaping", "orgy", "cleft_of_venus", "futanari", "futasub", "futa", "cumdrip", "fingering", "vibrator", "partially_visible_vulva", "penetration", "penetrated", "cumshot", "exhibitionism", "breast_milk", "grinding", "clitoral", "urethra", "phimosis", "cervix", "impregnation", "tribadism", "molestation", "pubic_hair", "clothed_female_nude_male", "clothed_male_nude_female", "clothed_female_nude_female", "clothed_male_nude_male", "sex_machine", "milking_machine", "ovum", "chikan", "pussy_juice_drip_through_clothes", "ejaculating_while_penetrated", "suspended_congress", "reverse_suspended_congress", "spread_pussy_under_clothes", ],
75
+ #外観状態/外觀狀態
76
+ "Appearance Status" : ["sweat", "sweaty", "sweatdrop", "nude", "tears", "blush", "wet", "blood", "saliva", "see-through", "tattoo", "makeup", "no_bra", "glowing", "scar", "bottomless", "halterneck", "skindentation", "shadow", "topless", "trembling", "crying", "sleeping","tan", "_skin", "breath", "_submerged", "injury", "butt_crack", "shibari", "drunk", "mole", "moles", "curvy", "transparent", "stitches", "peeing", "dripping", "latex", "leather", "dirty", "bruise", "pregnant", "crack", "crotchless", "hot", "_markings", "bodypaint", "hairy", "sideless", "outfit", "backless", "reverse", "cuts", "pantylines", "bleeding", "trefoil", "public_nudity", "covered_mouth", "from_mouth", "veins", "tanlines", "nosebleed", "lipstick_mark", "steaming_body", "cross-section", "x-ray", "body_writing", "wardrobe_malfunction", "tattoo", "soap_bubbles", "cold", "scratches", "steam", "visible_air", "bandaged_neck", ],
77
+ #動作姿勢/動作姿勢
78
+ "Action Pose" : ["sitting", "standing", "waving", "lying", "open_", "_open", "_lift", "pulled_by_self", "undressing", "undressed", "solo", "looking", "one_eye_closed", "closed_eye", "hands_", "arm_", "arms_", "hand_", "kneeling", "hug", "pov", "holding", "on_back", "hand_on", "on_bed", "arm_support", "back", "wariza", "arms_behind_back", "grabbing", "squatting", "_pull", "bdsm", "grabbing_", "bara", "straddling", "lifted_by_self", "pointing", "all_fours", "kiss", "_press", "licking", "finger_to_mouth", "seiza", "walking", "cigarette", "_wielding", "_hold", "_pose", "reaching", "jumping", "drinking", "smoking", "yokozuwari", "lactation", "lowleg", "reading", "headpat", "salute", "riding", "stretching", "battle", "presenting", "dancing", "on_ground", "V", "v", "bent_over", "pocky", "on_one_knee", "_grab", "kicking", "pigeon-toed", "in_container", "eating", "running", "talking", "pee", "biting", "singing", "_docking", "falling", "afterimage", "split", "trigger_discipline", "facing", "splashing", "aiming", "moaning", "feeding", "shouting", "cooking", "reclining", "punching", "_slip", "carry", "carrying", "floating", "wading", "_rest", "unzipped", "unzipping", "pinky_out", "playing", "shushing", "breast_suppress", "poking", "midair", "flashing", "flexible", "reverse_grip", "fighting", "afloat", "upright_straddle", "finger_on_trigger", "hiding", "exercise", "unbuttoned", "spill", "finger_to_cheek", "profanity", "paint", "in_mouth", "own_mouth", "another's_mouth", "over_mouth", "come_hither", "pinching", "shoe_dangle", "smell", "pump_action", "hand_on_wall", "against_wall", "fourth_wall", "against_fourth_wall", "shopping", "cheek_squash", "_peek", "tearing_clothes", "girl_on_top", "flying", "hugging", "vore", "flexing", "selfie", "covering", "tiptoes", "breathing", "gymnastics", "yawning", "planted", "pervert", "dressing", "teardrop", "firing", "smother", "expansion", "padding", "poke", "bondage", "bust_cup", "raised", "peeking", "unsheathing", "unsheathed", "wedgie", "pouring", "exposure", "kissing", "tsundere", "fishing", "swimming", "showering", "chewing", "staring", "piggyback", "throwing", "writing", "frogtie", "chained", "plantar_flexion", "dorsiflexion", "fetal_position", "giving", "jealous", "praying", "driving", "on_lap", "bite_mark", "screaming", "strangling", "turning_head", "suspension", "_up", "toothbrush", "hadanugi_dousa", "melting", "walk-in", "attack", "asphyxiation", "smelling", "kabedon", "caught", "petting", "spilling", "fleeing", "burning", "spanked", "twitching", "pulling", "dreaming", "imagining", "bathing", "destruction", "spinning", "sewing", "wrestling", "two-handed", "hairdressing", "tied_up", "painting_(action)", "squeezed", "shaking", "fallen_down", "freediving", ],
79
+ #頭部装飾/頭部服飾
80
+ "Headwear" : ["hat", "_headwear", "hairband", "hairclip", "earrings", "earring", "bespectacled", "halo", "headband", "beret", "headgear", "eyepatch", "scrunchie", "mob_cap", "helmet", "crown", "tiara", "hair_bobbles", "goggles", "eyewear_on_head", "facial", "_cap", "_eyewear", "_drills", "_drill", "hairpin", "hair_tie", "bandana", "blindfold", "antennae", "headpiece", "eyeliner", "beanie", "bandeau", "on_head", "antlers", "earmuffs", "veil", "mask", "headphones", "headset", "hair_ornament", "ear_ornament", "hood", "maid_headdress", "circlet", "tate_eboshi", "aura", "bonnet", "hachimaki", "topknot", "monocle", "fedora", "hairpods", "earclip", "earpiece", "pince-nez", "kanzashi", "earbuds", "qingdai_guanmao", "scarf_over_mouth", "head-mounted_display", "bandaged_head", "mask", "_mask", "glasses", "sunglasses", "beanie", "head_wreath", "headdress", "ear_covers", "earphones", "hair_rings", "nightcap", "mechanical_horns", "mechanical_ears", "mechanical_eye", "neck_ruff", "ear_tag", "diadem", "turban", "tam_o'_shanter", "kabuto_(helmet)", "visor", "helm", ],
81
+ #手部装飾/手部服飾
82
+ "Handwear" : ["armband", "gauntlets", "wristband", "_gauntlets", "armlet", "cuffs", "mittens", "bangle", "nail_polish", "bracelet", "bracelets", "_glove", "_gloves", "gloves", "kote", "bracer", "arm_warmers", "elbow_pads", "mechanical_arms", "mechanical_arm", "mechanical_hands", "yugake", "wrist_cuffs", "kurokote", "bandaged_arm", "bandaged_hand", "bandaged_wrist", "bandaged_fingers", "prosthetic_arm", "wrist_guards", ],
83
+ #ワンピース衣装/一件式服裝
84
+ "One-Piece Outfit" : ["dress", "leotard", "bodysuit", "bodystocking", "yukata", "kimono", "furisode", "hanfu", "robe", "overalls", "sundress", "microdress", "gown", "one-piece", "jumpsuit", ],
85
+ #上半身衣装/上半身服裝
86
+ "Upper Body Clothing" : ["shirt", "t-shirt", "jacket", "sweater", "vest", "sleeves", "sleeve", "choker", "necktie", "_uniform", "japanese_clothes", "serafuku", "sailor_collar", "apron", "armor", "cape", "coat", "hoodie", "maid", "bra", "collar", "uniform", "crop_top", "neckerchief", "strapless", "_collar", "ascot", "turtleneck", "cardigan", "tank_top", "blazer", "suspenders", "suit", "lingerie", "blouse", "_top", "corset", "camisole", "_torso", "sarashi", "shawl", "pajamas", "tabard", "sportswear", "spaghetti_strap", "gakuran", "haori", "muneate", "sleeveless", "tasuki", "shoulder_", "dougi", "aiguillette", "bustier", "harem_pants", "sode", "rei_no_himo", "hagoromo", "tie_clip", "tunic", "plunging_neckline", "bowtie", "scarf", "capelet", "coattails", "pauldrons", "pauldron", "cloak", "vambraces", "breastplate", "criss-cross_halter", "center_opening", "sundress", "waistcoat", "babydoll", "undershirt", "v-neck", "chest_jewel", "nightgown", "breast_curtains", "breast_curtain", "breast_pocket", "mechanical_wings", "sleepwear", "tailcoat", "raincoat", "chemise", "tuxedo", "swimsuit", "bikini", "negligee", "mizu_happi", "hanten_(clothes)", ],
87
+ #下半身衣装/下半身服裝
88
+ "Lower Body Clothing" : ["skirt", "miniskirt", "microskirt", "panties", "pantsu", "shorts", "underwear", "pants", "buruma", "hakama", "garter_straps", "denim", "side_slit", "thong", "jeans", "bloomers", "crotch_seam", "sarong", "knee_pads", "pelvic_curtain", "fundoshi", "cutoffs", "faulds", "loincloth", "petticoat", "hip_vent", "waist_cape", "swim_trunks", "mechanical_tail", "g-string", "overskirt", "bare_hips", "panty_straps", "briefs", ],
89
+ #足部衣装/腳部服裝
90
+ "Footwear" : ["socks", "boots", "shoes", "_heels", "_footwear", "sandals", "sneakers", "loafers", "tabi", "geta", "slippers", "mary_janes", "spikes", "anklet", "_shoe", "zouri", "flip-flops", "pumps", "kneehigh", "pantyhose", "thighhighs", "_legwear", "bandaged_leg", "leggings", "_sock", "skates", "okobo", "flats", "kneehighs", "over-kneehighs", "greaves", "uwabaki", "leg_warmers", "tengu-geta", "mechanical_legs", "prosthetic_leg", ],
91
+ #その他の装飾/其他服飾
92
+ "Other Accessories" : [ "frills", "_cutout", "plaid", "_clothes", "ribbon", "bow", "sash", "zettai_ryouiki", "buttons", "button", "_trim", "jewelry", "floral_print", "piercing", "obi", "formal", "cross", "polka_dot", "gem", "brooch", "casual", "_costume", "buckle", "clothes_writing", "pom_pom_(clothes)", "clothing_aside", "skin_tight", "lace", "alternate_", "zipper", "pendant", "beads", "pocket", "epaulettes", "pouch", "leash", "shrug_(clothing)", "anklet", "double-breasted", "holster", "_print", "belts", "belt", "necklace", "magatama", "strap", "cow_print", "shackles", "badge", "lanyard", "costume", "fishnets", "_garter", "medal", "tassel", "o-ring", "drawstring", "shimenawa", "fabric", "charm", "obijime", "obiage", "_ornament", "mechanical_parts", "_knot", "padlock", "_pin", "patterned_clothing", "spandex", "d-pad", "sweatband", "_stripe", "pom_pom_(clothes)", "(ornament)", ],
93
+ #表情/表情
94
+ "Facial Expression" : ["smile", "grin", ":o", "tongue", "tongue_out", "parted_lips", ":3", "^_^", "expressionless", "frown", "happy", ";d", ">_<", "?", ";(", "shaded_face", "^^^", "surprised", "...", "angry", ":<", "eye_contact", "restrained", ":p", "tsurime", "tareme", "!", "@_@", "jitome", ":q", "_face", "furrowed_brow", "wide-eyed", "+_+", "serious", "=_=", "smirk", "o_o", ":t", ";)", "pout", "|_|", "spoken_question_mark", "wince", "_mouth", "+++", "laughing", "w", ":>", ">:)", "anger_vein", "annoyed", "spoken_exclamation_mark", ":d", "sad", ":/", "._.", "0_0", "zzz", ";o", "puff_of_air", "sanpaku", "torogao", "sleepy", "fucked_silly", "ahegao", "d:", ":|", "\m/", "drooling", "shy", "xd", ";p", "turn_pale", ">:(", "gloom_(expression)", ";q", "thinking", "spoken_interrobang", "snot", "spoken_ellipsis", "embarrassed", "tearing_up", "!?", "smug", "scared", "x", "??", "nervous", "!!", "glaring", ":>=", "c:", "scowl", ":i", "sigh", ">_o", "\\||/", "\||/", "o3o", "grimace", "confused", "worried", ";3", "notice_lines", "squiggle", "u_u", "\n/", ],
95
+ #頭部/頭部
96
+ "Head" : ["_hair", "_eyes", "_eye", "_pupils", "third_eye", "eyeshadow", "hair_flaps", "teeth", "ahoge", "sidelocks", "sidelock", "_bangs", "blunt_bangs", "hair_bun", "_bun", "one_eye", "parted_bangs", "braids", "braid", "fang", "eyelashes", "v-shaped_eyebrows", "head_tilt", "animal_ear_fluff", "two_side_up", "lips", "heterochromia", "one_side_up", "swept_bangs", "hair_intakes", "facial_mark", "eyebrows", "eyebrow", "bob_cut", "buzz_cut", "hime_cut", "eyebrow_cut", "bowl_cut", "mouth_", "hair_tubes", "_horns", "_horn", "forehead", "faceless", "_sclera", "horns", "half_updo", "freckles", "dot_nose", "kemonomimi_mode", "sideburns", "skull", "hair_", "stubble", "beard", "mustache", "goatee", "nose", "hime_cut", "undercut", "bald", "facepaint", "blunt_ends", "one-eyed", "colored_tips", "in_eye", "snout", "pompadour", "updo", "twintails", "ponytail", "tails", "eyeball", "whiskers", "ringlets", "cowlick", "mascara", "mohawk", "enpera", "dreadlocks", "afro", "inverted_bob", ],
97
+ #手部/手部
98
+ "Hands" : ["_arm", "_arms", "fingernails", "_nails", "_nail", "_fingers", "_finger", "claws", "_hand", "thumbs_up", "rings", ],
99
+ #上半身/上半身
100
+ "Upper Body" : ["breasts", "cleavage", "collarbone", "midriff", "navel", "stomach", "_ears", "armpits", "armpit", "_shoulders", "_shoulder", "sideboob", "flat_chest", "underboob", "abs", "pectorals", "toned", "underbust", "shoulder_blades", "harness", "ribs", "breast_rest", "kariginu", "lapels", "button_gap", "strap_gap", "linea_alba", "feather_boa", "biceps", "belly", "downblouse", "backboob", "dimples_of_venus", "spacesuit", "median_furrow", "nape", "spine", ],
101
+ #下半身/下半身
102
+ "Lower Body" : ["ass", "thighs", "tail", "legs", "feet", "toes", "thigh_strap", "barefoot", "highleg", "thigh_gap", "_thighhigh", "toenails", "toenail", "wide_hips", "kneepits", "thighlet", "soles", "knees", "crotch", "toe_scrunch", "ankles", "hip_bones", "hooves", ],
103
+ #生物/生物
104
+ "Creature" : ["animal", "(animal)", "bug", "ladybug", "bee", "cat", "bird", "butterfly", "tentacles", "lion", "fish", "dog", "rabbit", "dragon", "snake", "creature", "chinese_zodiac", "frog", "horse", "mouse", "fox", "chick", "crab", "bear", "tiger", "octopus", "duck", "sheep", "seagull", "fish", "goldfish", "starfish", "jellyfish", "clownfish", "anglerfish", "shrimp", "fox", "penguin", "wolf", "crow", "chicken", "owl", "frog", "panda", "shark", "pig", "snail", "hamster", "whale", "coral", "dove", "pigeon", "turtle", "tanuki", "rooster", ],
105
+ #植物/植物
106
+ "Plant" : ["flower", "(flower)", "spider_lily", "rose", "leaf", "plant", "cherry_blossoms", "bouquet", "hibiscus", "hydrangea", "gourd", "bamboo", "flower", "tree", "bush", "lily_pad", "lotus", "plum_blossoms", "petals", "branch", "vines", "sunflower", "clover", "thorns", "moss", "daisy", "tulip", "wisteria", ],
107
+ #食べ物/食物
108
+ "Food" : ["food", "_(food)", "fruit", "_(fruit)", "sweets", "candy", "dessert", "wagashi", "berry", "strawberry", "blueberry", "raspberry", "pasties", "apple", "bread", "pumpkin", "cake", "popsicle", "lollipop", "chocolate", "ice_cream", "peach", "mushroom", "doughnut", "cookie", "cherry", "burger", "egg", "meat", "dango", "noodles", "mandarin_orange", "takoyaki", "sushi", "banana", "pizza", "lemon", "tomato", "cream", "parfait", "baozi", "spitroast", "mochi", "cheese", "ramen", "pudding", "french_fries", "bento", "carrot", "vegetable", "cabbage", "radish", "spring_onion", "onion", "lettuce", "potato", "cucumber", "eggplant", "beans", "chili_pepper", "broccoli", "coconut", "corn", "cucumber", "seaweed", "sweet_potato", "roasted_sweet_potato", "rice", "wagashi", "cupcake", "baguette", "omelet", "omurice", "tamagoyaki", "sausage", "tempura", "watermelon", "melon", "grapes", "onigiri", "macaron", "sandwich", "pancake", "pineapple", "pastry", "curry", "skewer", "taiyaki", "toast", "crepe", ],
109
+ #飲み物/飲品
110
+ "Beverage" : ["drink", "coffee", "alcohol", "tea", "beer", "sake", "milk", "juice", "juice_box", "whiskey", "wine", "soda", "cola", ],
111
+ #音楽/音樂
112
+ "Music" : ["concert", "band", "instrument", "(instrument)", "guitar", "drumsticks", "drum", "flute", "piano", "trumpet", "violin", "cello", "harp", "horn", "lyre", "recorder", "idol", "microphone", "(music)", "music", "musical_note", "beamed", "whistle", "megaphone", "sound_effects", "quarter_note", "eighth_note", "sixteenth_note", "plectrum", "baton_(conducting)", "phonograph", "utaite", ],
113
+ #武器・装備/武器・裝備
114
+ "Weapons & Equipment" : ["(weapon)", "weapon", "sword", "hammer", "katana", "knife", "polearm", "sheath", "gun", "rifle", "shield", "spear", "wand", "scythe", "dagger", "axe", "scabbard", "torpedo", "lance", "trident", "bullet", "gohei", "scope", "bolt_action", "rapier", "kunai", "grenade", "bullpup", "staff", "energy_sword", "cannon", "handgun", "sheathed", "baseball_bat", "tank", "explosive", "bomb", "whip", "suppressor", "quiver", "revolver", "shotgun", "chainsaw", "mallet", "rocket_launcher", "fighter_jet", "jet", "ammunition", "bandolier", "shuriken", "holstered", "arrow_(projectile)", "nata_(tool)", ],
115
+ #乗り物/交通器具
116
+ "Vehicles" : ["bicycle", "motor_vehicle", "motorcycle", "car", "aircraft", "airplane", "ship", "boat", "watercraft", "flight_deck", "spacecraft", "train", "wheel", "wheelchair", "wheelbarrow", "caterpillar_tracks", "truck", "spoiler_(automobile)", "helicopter", ],
117
+ #建物/建物
118
+ "Buildings" : ["architecture", "building", "library", "cafe", "aquarium", "gym", "restaurant", "toilet", "restroom", "(place)", "castle", "shop", "rooftop", "house", "apartment", "church", "train_station", "hospital", "skyscraper", "stadium", "temple", "tower", "balcony", "porch", "veranda", "hallway", "stage", ],
119
+ #室内/室內
120
+ "Indoor" : ["shelf", "bookshelf", "desk", "indoors", "sliding_doors", "doorway", "school_desk", "bed_sheet", "bed", "chair", "window", "table", "curtains", "_floor", "mirror", "stairs", "door", "blanket", "tatami", "bath", "stool", "chalkboard", "cushion", "pillow", "dakimakura", "futon", "kotatsu", "locker", "throne", "floor", "ceiling", "shouji", "classroom", "cupboard", "interior", "bathtub", "carpet", "sink", "counter", "rug", "drawer", "windowsill", "room", "storeroom", "kitchen", "bathroom", "bedroom", ],
121
+ #屋外/室外
122
+ "Outdoor" : ["outdoors", "day", "night", "ocean", "beach", "sky", "sunset", "tree", "moon", "sunlight", "crescent", "snow", "forest", "rock", "mountain", "turret", "sand", "sun", "onsen", "pool", "bush", "road", "torii", "bridge", "fence", "railing", "utility_pole", "lake", "street", "grass", "valley", "hill", "snowball", "crosswalk", "poolside", "river", "snowman", "waterfall", "smokestack", "ferris_wheel", "path", "cliff", "village", "town", "city", "shore", "desert", "cave", "arch", "lamppost", "field", "(city)", "alley", "bus_stop", "tent", ],
123
+ #物品/物品
124
+ "Objects" : ["cup", "bag", "handbag", "book", "bell", "chain", "phone", "umbrella", "bandages", "stuffed_toy", "ring", "backpack", "cellphone", "feathers", "bottle", "(bottle)", "fire", "letterboxed", "towel", "bandaid", "bandaids", "box", "rope", "couch", "plate", "gift", "ball", "tray", "broom", "condom", "innertube", "watch", "drinking_straw", "teddy_bear", "paper", "lantern", "mug", "chopsticks", "card", "ofuda", "can", "spoon", "fork", "tiles", "doll", "folding_fan", "emblem", "android", "clock", "basket", "pen", "flag", "lamp", "bench", "bucket", "key", "anchor", "randoseru", "sack", "computer", "(computer)", "teapot", "camera", "controller", "parasol", "paintbrush", "(object)", "handheld_game_console", "coin", "shell", "sakazuki", "scroll", "scissors", "saucer", "tape", "clipboard", "chess_piece", "orb", "laptop", "bone", "money", "ladle", "statue", "gears", "pole", "stick", "hose", "lock", "barcode", "letter", "jar", "silk", "test_tube", "game_console", "remote_control", "shide", "kiseru", "cage", "lifebuoy", "needle", "map", "calligraphy_brush", "banner", "stylus", "briefcase", "figure", "binoculars", "toy", "frying_pan", "speaker", "electric_fan", "lotion", "flask", "ladder", "yunomi", "cigar", "wallet", "treasure_chest", "model_kit", "video_game", "box_art", "id_card", "cutting_board", "shopping_cart", "teacup", "bowl", "joystick", "sticker", "smartphone", "glass", "candle", "balloon", "string", "cowbell", "lipstick", "jack-o'-lantern", "watch", "wristwatch", "pocket_watch", "pendant_watch", "stopwatch", "beachball", "basketball", "volleyball", "baseball", "handcuffs", "suction_cups", "choko_(cup)", "pan", "pencil", "television", "monitor", "syringe", "(gemstone)", "gemstone", "gold", "vase", "suitcase", "notebook", "cane", "nintendo_switch", "armchair", "soap", "pc", "viewfinder", "fishing_rod", "envelope", "uchiwa", "wrench", "digital_media_player", "shovel", "newspaper", "pencil", "dice", "pinwheel", "stethoscope", "seashell", "shower_head", "glowstick", "paddle", "talisman", "pill", "tombstone", "quill", "tokkuri", "spatula", "candlestand", "wreath", "mop", "liquid", "eraser", "pack", "torch", "satchel", "surfboard", "patch", "vial", "cartridge", "drawing_tablet", "_machine", "cosmetics", "racket", "sketchbook", "(computing)", "keychain", "comb", "origami", "iphone", "nintendo", "chandelier", "marker", "pointer", "(container)", "(playing_card)", "poke_ball", "chess", "(chess)", "traffic_cone", "crazy_straw", "whisk", "board_game", ],
125
+ #キャラクター設定/角色設定
126
+ "Character Design" : ["girl", "boy", "_girls", "_boys", "+girls", "+boys", "male_focus", "_female", "_male", "virtual_youtuber", "loli", "no_humans", "cosplay", "pokemon", "couple", "aged_down", "robot", "sisters", "elf", "furry", "otoko_no_ko", "1other", "child", "genderswap", "mecha", "androgynous", "persona", "age_difference", "miko", "abyssal_ship", "machinery", "_person", "twins", "monster", "aged_up", "mature_female", "ghost", "height_difference", "oni", "fins", "brother_and_sister", "borrowed_character", "contemporary", "interracial", "shota", "nun", "angel", "cheerleader", "hitodama", "witch", "pom_pom_(cheerleading)", "magic", "petite", "fantasy", "ninja", "fairy", "joints", "nurse", "waitress", "rigging", "gyaru", "bishounen", "multiple_others", "mother_and_daughter", "military", "idol", "interspecies", "giant", "old", "yuri", "siblings", "draph", "fat", "manly", "brothers", "erune", "yin_yang", "miqo'te", "heads_together", "yukkuri_shiteitte_ne", "race_queen", "nekomata", "cyborg", "_connection", "jiangshi", "superhero", "skeleton", "expressions", "side-by-side", "broken", "bride", "mind_control", "karakasa_obake", "take_your_pick", "plump", "size_difference", "habit", "_fur", "scales", "muscular", "disembodied_", "prosthesis", "damaged", "time_paradox", "family", "zombie", "albino", "yandere", "others", "amputee", "danmaku", "demon", "alien", "skinny", "humanization", "netorare", "ambiguous_gender", "defeat", "baby", "clone", "hypnosis", "death", "fusion", "command_spell", "sailor", "horror_(theme)", "mother_and_son", "shrine", "dancer", "kyuubi", "lamia", "beak", "reverse_trap", "harem", "fashion", "harpy", "taur", "radio_antenna", "paint_splatter", "transformation", "kogal", "egyptian", "surreal", "left-handed", "au_ra", "talons", "duel", "submerged", "guro", "corruption", "rod_of_remorse", "super_saiyan", "scene_reference", "fluffy", "real_life_insert", "tusks", "obliques", "puppet", "jirai_kei", "health_bar", "meta", "what", "_man", "fangs", "playboy_bunny", "wings", "poi", "minigirl", "chibi", "enmaided", "jeweled_branch_of_hourai", "(genshin_impact)", "gameplay_mechanics", "crossover", "school", "pantyshot", "alternate_muscle_size", "dwarf", "japari_bun", "crossdressing", "lolita", "electricity", "everyone", "office_lady", "suggestive", "vampire", "plugsuit", "mermaid", "breathing_fire", "personification", "(overwatch)", "(youkai_watch)", "(emblem)", "watching_television", "(cosplay)", "(creature)", "under_covers", "onee-shota", "groom", "wedding", "on_body", "personality", "strongman", "narrow_waist", "kitsune", "camouflage", "oversized_object", "animalization", "police", "giantess", "(arknights)", "pun", "father_and_daughter", "wing", "tomboy", "knight", "breast_envy", "breast_conscious", "(jojo)", "husband_and_wife", "slime_(substance)", "v-fin", "teacher", "policewoman", "you_gonna_get_raped", "father_and_son", "(ff11)", "milestone_celebration", "slave", "player_2", "object_namesake", "miniboy", "(touhou)", "(fate)", "(fate/stay_night)", "darkness", "soldier", "evolutionary_line", "world_war_ii", "orc", "pirate", "instant_loss", "keyhole", "matching_outfits", "pawpads", "princess", "sangvis_ferri", "wife_and_wife", "(pokemon)", "cyberpunk", "samurai", "striker_unit", "look-alike", "year_of", "corpse", "boxers", "spiked_shell", "insignia", "ufo", "cyclops", "cheating_(relationship)", "hyur", "trick_or_treat", "drone", "fewer_digits", "assault_visor", "team_rocket", "when_you_see_it", "monsterification", "traditional_youkai", "(kancolle)", "(houseki_no_kuni)", "39", "yordle", "bartender", "tall", "kodona", "(kill_la_kill)", "harvin", "spokencharacter", "ass-to-ass", "(blue_archive)", "(project_sekai)", "(grimm)", "(meme)", "(hyouka)", "(alice_in_wonderland)", "(fire_emblem)", "(yu-gi-oh!_gx)", "(machimazo)", "(league_of_legends)", "(kantai_collection)", "(evangelion)", "(nier:automata)", "(idolmaster)", "(zelda)", "(lyomsnpmp)", "(splatoon)", "(tsukumo_sana)", "(madoka_magica)", "(project_moon)", "(legends)", "(organ)", "(mecha)", "nanodesu_(phrase)", "(sao)", "fumo_(doll)", "three-dimensional_maneuver_gear", "creature_and_personification", "nontraditional", "_challenge", "you're_doing_it_wrong", "gibson_les_paul", "elezen", "fuuin_no_tsue", "goblin", "sidesaddle", "pet_play", "_interface", ],
127
+ #構図/構圖
128
+ "Composition" : ["full_body", "upper_body", "lower_body", "cowboy_shot", "close-up", "from_behind", "from_side", "from_below", "from_above", "photorealistic", "blurry", "profile", "dutch_angle", "multiple_views", "comic", "monochrome", "greyscale", "1koma", "2koma", "3koma", "4koma", "5koma", "depth_of_field", "leaning", "leaning_forward", "leaning_to_the_side", "border", "sketch", "on_side", "traditional_media", "parody", "bound", "portrait", "foreshortening", "meme", "science_fiction", "lens_flare", "out_of_frame", "contrapposto", "upside-down", "realistic", "oekaki", "sideways_glance", "horizon", "_focus", "straight-on", "chromatic_aberration", "silhouette", "retro_artstyle", "_style", "(style)", "painting", "tachi-e", "bad_anatomy", "wide_shot", "outline", "spot_color", "limited_palette", "halftone", "face-to-face", "cheek-to-cheek", "back-to-back", "cover", "marker_(medium)", "(medium)", "partially_colored", "lineart", "fake_screenshot", "jaggy_lines", "picture_frame", "flat_color", "sepia", "poster_(object)", "recording", "taking_picture", "muted_color", "colorful", "still_life", "too_many", "lineup", "collage", "shikishi", "heads-up_display", "animification", "upskirt", "partially_underwater_shot", "underwater", "sandwiched", "film_grain", "perspective", "(texture)", "fisheye", "pillarboxed", "abstract", "left-to-right_manga", "anime_coloring", "glitch", "color_guide", "cameo", "reference_inset", "circle_cut", "high_contrast", "product_placement", "turnaround", "variations", "tegaki", "side-by-side", "symmetry", "sideways", "dominatrix", "mixed_media", ],
129
+ #季節/季節
130
+ "Season" : ["festival", "christmas", "halloween", "new_year", "_day", "valentine", "anniversary", "tanabata", "spring_(season)", "summer", "autumn", "winter", "birthday", "nengajou", "akeome", "kotoyoro", ],
131
+ #背景/背景
132
+ "Background" : ["_background", "water", "motion_lines", "wind", "scenery", "nature", "light_particles", "rain", "bubble", "emphasis_lines", "_theme", "ice", "crystal", "light_rays", "glint", "motion_blur", "smoke", "confetti", "cable", "light", "space", "shade", "dark", "sparkle", "explosion", "ruins", "ripples", "planet", "pillar", "reflection", "bokeh", "energy", "puddle", "egasumi", "fog", "shooting_star", "constellation", "contrail", "debris", "embers", "bloom", "dusk", "wooden_wall", "tile_wall", "stone_wall", "brick_wall", "wall_of_text", "wall_clock", "star_(sky)", "backlighting", "snowing", "mountainous_horizon", "lightning", "cityscape", "fireworks", "sunbeam", "speed_lines", "twilight", "evening", "crowd", "landscape", "spider_web", "(planet)", "spotlight", "sidelighting", "sunburst", "moonlight", "people", "graffiti", "wire", "lights", "dust", "caustics", "footprints", "sparks", "industrial_pipe", "cloud", "snowflakes", "rainbow", "power_lines", "waves", "sunrise",],
133
+ # パターン/圖案
134
+ "Patterns" : ["arrow", "symbol", "sign", "shape", "(shape)", "(symbol)", "treble_clef", "bass_clef", "triangle", "tally", "pattern", "(pattern)", "pentagram", "heart", "roman_numeral", "hexagram", "hexagon", "blank_censor", "light_censor", "cube", "circle", "tube", "yagasuri", ],
135
+ #検閲/審查
136
+ "Censorship" : ["uncensored", "censored", "_censoring", "_censor", "maebari", "convenient", "soap_censor", "heart_censor", "hair_censor", "novelty_censor", "blur_censor", "steam_censor", "identity_censor", "tail_censor", "character_censor", ],
137
+ #その他/其他
138
+ "Others" : ["reference_sheet", "layer", "english_text", "speech_bubble", "text", "page_number", "dated", "copyright", "signature", "logo", "name", "character_name", "artist", "artist_name", "username", "cover_page", "ranguage", "content_rating", "03:00", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "thank_you", "subtitled", "numbered", "wallpaper", "asian", "(company)", "watermark", "web_address", "japan", "artistic_error", "typo", "pixiv_id", ],
139
+ }
140
+
141
+ # Use dictionary comprehension to reverse key-value pairs
142
+ reversed_categories = {value: key for key, values in categories.items() for value in values}
143
+
144
+
145
+ tags = []
146
+
147
+ if __name__ == "__main__":
148
+ classify_tags (tags, True)
149
+
requirements.txt CHANGED
@@ -4,7 +4,7 @@ pillow>=9.0.0
4
  onnxruntime>=1.12.0
5
  huggingface-hub
6
 
7
- gradio==5.12.0
8
  pandas
9
 
10
  # for reorganize WD Tagger into a readable article by Llama3 model.
 
4
  onnxruntime>=1.12.0
5
  huggingface-hub
6
 
7
+ gradio==5.14.0
8
  pandas
9
 
10
  # for reorganize WD Tagger into a readable article by Llama3 model.