reluce / szurubooru-toolkit

Python package and script collection to manage your szurubooru image board.
GNU General Public License v3.0
43 stars 14 forks source link

Deepbooru tag issue with missing rating due to threshold #57

Closed nateify closed 1 month ago

nateify commented 2 months ago

I noticed that Deepbooru did not include a rating on a particular output, which also caused a tag to be missed as it was assumed by the toolkit to be a rating. I am using the latest 2022 release of the model and tags.txt from here: https://github.com/KichangKim/DeepDanbooru/releases/tag/v3-20211112-sgd-e28

Log file of szuru-toolkit:

[DEBUG] [07.09.2024, 01:20:09 EDT] [deepbooru.tag_image] Guessed following tags: ['1girl', 'blonde_hair', 'blue_background', 'blue_eyes', 'bodysuit', 'breasts', 'cleavage', 'gradient', 'gradient_background', 'large_breasts', 'lips', 'long_hair', 'no_bra', 'ponytail', 'scrunchie', 'signature', 'solo', 'zero_suit', 'samus_aran']
[DEBUG] [07.09.2024, 01:20:09 EDT] [utils.convert_rating] Converted rating samus_aran to None
[DEBUG] [07.09.2024, 01:20:09 EDT] [deepbooru.tag_image] Guessed rating None

When I ran deepdanbooru externally, it guessed the rating with a threshold lower than what I set with my toolkit config: (0.603) rating:safe

I think that the rating should be assumed safe as a default if the guessed tags don't include a "rating:" item (or user configurable). This way the image would have still been tagged with "samus_aran"

reluce commented 2 months ago

I added default_safety as an option in config.toml (auto_tagger section). If not set, it would default to safe. You can test it out in the 1.0.2 branch.

nateify commented 2 months ago

I added default_safety as an option in config.toml (auto_tagger section). If not set, it would default to safe. You can test it out in the 1.0.2 branch.

It added a rating, but still missed the last tag in the initial list. In the following example "shiranui_mai" doesn't get tagged even though it is above the threshold, and exists:

[INFO] [08.09.2024, 12:54:22 EDT] [auto_tagger.main] Found 1 posts. Start tagging...
[DEBUG] [08.09.2024, 12:54:24 EDT] [deepbooru.tag_image] Guessed following tags: ['1girl', 'breasts', 'brown_eyes', 'brown_hair', 'cloud', 'day', 'folding_fan', 'hand_fan', 'lips', 'sky', 'solo', 'shiranui_mai']
[DEBUG] [08.09.2024, 12:54:24 EDT] [deepbooru.tag_image] Deepbooru could not guess rating for image! Falling back to safe
[DEBUG] [08.09.2024, 12:54:25 EDT] [szurubooru.update_post] Updating following post: Post(id: 795, source: https://XXXX, content_url: https://XXXX/data/posts/XXXX.jpg, version: 5, relations: [], tags: ['brown_hair', '1girl', 'folding_fan', 'deepbooru', 'hand_fan', 'lips', 'absurdres', 'solo', 'day', 'parsujera', 'highres', 'breasts', 'brown_eyes', 'sky', 'cloud'], safety: safe
[DEBUG] [08.09.2024, 12:54:25 EDT] [szurubooru.update_post] Using query_url: https://XXXX/api/post/795
[DEBUG] [08.09.2024, 12:54:25 EDT] [szurubooru.update_post] Using payload: {"version": 5, "tags": ["brown_hair", "1girl", "folding_fan", "deepbooru", "hand_fan", "lips", "absurdres", "solo", "day", "parsujera", "highres", "breasts", "brown_eyes", "sky", "cloud"], "source": "https://XXXX", "safety": "safe"}
[SUCCESS] [08.09.2024, 12:54:25 EDT] [auto_tagger.print_statistics] Script has finished tagging.
reluce commented 2 months ago

Thanks for testing it out, I just pushed another commit which should fix that issue.

nateify commented 2 months ago

Seems to work perfectly now!

reluce commented 1 month ago

Fixed in 1.0.2.