News:

Please request registration email again and then check your "Spam" folder

Former www.henthighschool.com

Automated tagging

Started by neronero, Jun 19, 2023, 10:06 AM

Previous topic - Next topic

Goldo

Hi guys, sorry most of the discussion went way over my head but I just wanted to remind you that tagging works best when it is WYSIWYG, all logic should be left for the game code to handle.

Not only is it much easier and flexible (no need to redo all girl packs and tags if you want to change a game rule), but it also makes the tags more 'universal' in case another game comes along using tags in the future (who knows, another project of mine?).
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

echoeater

Scrolling through all this discussion and getting a little lost. Can someone summarize what the current instructions and most up to date files/settings for using the autotagger are at this point?

Jman

No idea. There were at least two tools here: a ML tool to generate booru-style tags into filenames, and a modified tagger tool to convert those to more convenient BK-specific tag combos. The last downloadable version of the latter seems to be this (a few modified scripts for the actual tagger tool). I don't know if sjeongjin had a more advanced version in the end, and whatever scraps I have almost certainly won't match his.


The exact ML tool used seems to have changed over time and I've never used one myself. The last mention of one links to this. Perhaps the mighty hamster can help us out here?
And with strange aeons even death may die...

Ch12

Hi,

I wanted to give a short heads-up that I've been working on automated tagging for a week or so. (Kudos to Jman for pointing this thread here out to me.)

I'll start with saying that I will take a different approach. I understand that integrating this into the tagging tool is a quick solution, but I do not think hard-coding a couple of rules is something that we can scale to the proportions we need here.

I think the most obvious part is the discussion about what thresholds to use, and which tags. There are 120 tags in the extended tagset. More importantly, there are hundred-thousands (or millions?) of booru tags. Trying to manually connect these two sides would be a herculean tasks even without assigning weights and confidence thresholds.


I think there are two approaches to automated BK tagging:
- Train your own AI. The current auto-taggers use the booru-tags, but you could train one to directly spit out BK tags.
- Train a classifier, which would basically act as a translator from booru-tags to BK-tags.


Although it is the more direct approach, I've decided to not explore option 1, for the following reasons:
- I took a look into the Auto-tagger source-code, but could not find anything I could directly and easily reuse for building my own model.
- The potential training data (our girlpacks) probably has all kinds of biases. There's almost no images for some tags. There's probably also different biases among the girl pack creators. I simply lack the knowledge for how to account for that in AI training.
- I assume training a modern AI is quite costly. Even Deepseek, which made headlines just recently for being "really cheap", cost millions of dollars to train. (A small AI like an auto-tagger is probably cheaper still, but it still looks like the cost could escalate easily)


While on the other hand, the existing (booru-style) taggers are ready for use, trained with millions of images and tags from the booru sites. I do not thing BK can rival that in any way or scale.

Be we can leverage the booru taggers. I do have a bit of knowhow when it comes to good old machine learning, and this actually looks like a perfect usecase for it:
- We have input features (booru tags)
- We have output features (bk tags), basically each being a Yes/No decision
- We have labeled training data, meaning a supervised learning approach is possible.


Long-story short, I'm working on a classifier that takes the output of the WD14 tagger and transforms it into BK tags.
I have a first prototype that uses a very simple linear classifier, and the results are encouraging.

- There are some tags that are being tagged very well, usually ones that are very clearly defined and have many training images. (e.g. titjob or beach)
- There are some tags that are doing OK, often ones that are a bit fuzzily defined or covering different types of images. (E.g. profile or sub)
- And some are doing badly. Often ones with few examples and/or unclear definitions. The tag that's doing worst is "sensitivity". It's only at 20% accuracy.


I have decided against uploading a preview version. Right now, everything is being held together by duct tape (figuratively speaking), and I have to take multiple manual steps for both training a classifier, and also for using it.

But I hope I'll have something useable ready within a week. I'll probably also explore if complex models, like neural networks or kernel-SVM, can improve the classification accuracy.
Download My High Quality Girlpacks
Belldandy, Urd, Kaenbyou Rin, Jessica Albert, Kino Makoto (Sailor Jupiter), Temari, Tohsaka Rin, Pyra, Lyndis, Atago, Zelda, Kasumi, Camilla, Ningguang

Jman

#184
How exactly are you evaluating the BK-auto-tagging performance? Using an existing girl pack, running it through the auto-tagger and comparing the resulting booru tags vs manual tags? Are you using packs from many different authors?



It sounds like a potentially quite useful tool, even if for just a first pass through a pack. But, just to be contrarian... ;D The really obvious tags don't really need an extra layer of BK-specific training. If booru tags say 'titjob', 'titfuck' or 'paizuri', you can just chuck all of those into 'titjob' and be 99% sure this is okay and nothing was missed. This can be more easily accomplished by just a few rules instead of an extra training layer, one with massively less training data on top.

But once we come to tags where our human taggers themselves don't have any sort of strong consensus on what e.g. 'sensitivity' means, well, GIGO? :P
And with strange aeons even death may die...

Ch12

#185
Quote from: Jman on Feb 02, 2025, 04:18 PMHow exactly are you evaluating the BK-auto-tagging performance? Using an existing girl pack, running it through the auto-tagger and comparing the resulting booru tags vs manual tags? Are you using packs from many different authors?

Yes and no. I use (my) existing girlpacks and run them through the auto-tagger. The comparison part is completely being automated though, using machine learning. This will learn patterns that humans simply would miss. (or at least, that's the plan)

I've decided to use only the girlpacks I tagged myself as training data. (I hope) I tagged the images in a mostly consistent way, using a WYSIWYG approach.
I guess there are still some inconsistencies, like image scarcity leading to some images being tagged a bit differently for different characters.
I also noticed that I have two "natual" catgirls (Rin Kaenbyou and Atago), and they badly mess with the catgirl tag. (Unsurprisingly, it confuses the training when there's hundreds of catgirl images that for some reason are not to be tagged as catgirl...)

There may be some other "problems" I have not even noticed yet. Still, I have about 20k image in total, and I've usually been quite thorough with my tagging, so I think/hope this will suffice as labled training data. The remaining inconsistencies the model will simply have to learn to handle.


Regarding the logic, even "titjob" is not as simple as you might think. Here are the first 15 weigths for my titjob classifier: (and this is one of the most straightforward tags of all)

paizuri    2,02
teamwork -0,76
cooperative_paizuri        0,47
breasts_squeezed_together    0,35
symmetrical_docking    0,34
paizuri_under_clothes    0,29
perpendicular_paizuri    0,19
after_paizuri    0,15
threesome    0,15
deep_skin    -0,15
ffm_threesome    -0,14
censored    -0,14
mosaic_censoring    0,13
cum_on_breasts    0,11
1boy    0,10


You are correct that there is one dominant tag, but even here there are some helper tags that can improve accuracy. "Sister tags" like "cooperative_paizuri" or "paizuri_under_clothes", correlating tags like "breasts_squeezed_together". It would be hard trying to find those manually for a hundred BK tags.

On a side note, you can also notice some tags which I'd prefer to not see in my classifier, like "censored" and "mosaic_censoring". I guess these two are kinda evening out in this particular case, (one being positive and the other negative), but they're still a sign of overfitting and e.g. a bar-censor would be treated slightly differently.

Still, these two censoring weights are rather low, so overall this looks pretty good to me. One more thing to consider is that these classifiers can learn to look for the absence of tags. e.g. the "profile" classifier came out like this:

lying    -1,31
solo    1,18
cowboy_shot    1,12
standing    0,74
saliva    -0,73
vaginal    -0,71
sensitive    0,63
pussy    0,58
explicit    -0,54
penis    0,50
solo_focus    0,46
questionable    0,39

At the very top spot is "lying" with a negative weight. Which makes sense, because images with the girl lying would be classified as "rest" in most cases.

Again, the classifier looks reasonable overall - although I guess with the exception of "penis". I have no clue how that landed in the classifier for profile, which should be images of only the girl...


One more thing to mention is that I train including the prediction confidence from the autotagger, not just if a tag is there or not. So, the plan is that the classifier will learn by itself to judge if a paizuri prediction with e.g. only 20% confidence should get a titjob tag or not.
Download My High Quality Girlpacks
Belldandy, Urd, Kaenbyou Rin, Jessica Albert, Kino Makoto (Sailor Jupiter), Temari, Tohsaka Rin, Pyra, Lyndis, Atago, Zelda, Kasumi, Camilla, Ningguang

Ch12

#186
Quote from: Jman on Feb 02, 2025, 04:18 PMBut once we come to tags where our human taggers themselves don't have any sort of strong consensus on what e.g. 'sensitivity' means, well, GIGO? :P

Well, considering how the thing seems unable to distill any patterns for the sensitivity tag, I do not seem to have a strong consensus even with myself. :D
Download My High Quality Girlpacks
Belldandy, Urd, Kaenbyou Rin, Jessica Albert, Kino Makoto (Sailor Jupiter), Temari, Tohsaka Rin, Pyra, Lyndis, Atago, Zelda, Kasumi, Camilla, Ningguang