picobyte / stable-diffusion-webui-wd14-tagger

Labeling extension for Automatic1111's Web UI
539 stars 64 forks source link

Option to include ratings in tag files #60

Closed dark-edgelord closed 9 months ago

dark-edgelord commented 10 months ago

An option to include ratings (safe, questionable etc.) in the tag txt files would be nice, as I also use the tagger for organizational purposes and not just for training. The program already supports displaying these, it just excludes them from the txt files, so it shouldn't be a big deal.

picobyte commented 10 months ago

Can't say I care too much for this. There may be some interrogators that already place ratings, prepended with 'rating:' with the tags, or I may have fixed that. If you want to then it could be a checkbox in the settings, then around here You could populate, dependent on that option, using:

write_ratings_to_tags = getattr(shared.opts, 'tagger_write_ratings_to_tags', False)

for rating, val in ratings:
    if write_ratings_to_tags:
        current = cls.for_tags_file[data[1]].get(rating, 0.0)
        cls.for_tags_file[data[1]][rating] = min(val + current, 1.0)
dark-edgelord commented 9 months ago

Don't know if I added the code right, but it includes every rating instead of the best one.

1694082746

picobyte commented 9 months ago

It's about right, the val can be filtered on threshold. It's a weight between 0 and 1, so then if write_ratings_to_tags and val > cls.threshold: BTW it could also be placed in the existing loop. The threshold will be the same as for the tags, otherwise use a fixed floating point number (e.g. 0.35) or you will have to make another slider. HTH

PaperOrb commented 4 months ago

Does this trick not work any more? I inserted the code inside uiset.py identically to the screenshot above and I don't see any new tickbox after restarting webui.sh and the rating tags don't get added to the tags files.