kohya-ss / sd-scripts

Apache License 2.0
5.14k stars 856 forks source link

Assigning Keep Token per file #532

Open GuileGaze opened 1 year ago

GuileGaze commented 1 year ago

Right now Keep Token only works per folder rather than per file. For training which consists of multi-part outfits or multiple concepts, this can be a fairly large limitation due to the varying number of tokens that should be trained per file.

For example, let's say I want to train one character and 5 articles of clothing which make the outfit: character, hat, necklace, shirt, shorts, boots. Upper body shots will only include character, hat, necklace, shirt. Some of them might not even include the necklace and would only have character, hat, shirt. Full body shots would use all 6 tokens. That means that there's potentially 6 different folders needed to properly assign keep token values. That's not the biggest issue by itself since 6 folders isn't too many, but the problem becomes larger when wanting to define repeats and can grow exponentially for each new token you want to train.

As an actual example, I'm planning on retraining this LoRA which consists of 5 trained tokens. I currently have 3 folders for a different number of repeats. Currently I'm settling with keep token = 1 which is for the character herself, but if I wanted to set keep token values to include her outfit I'd need 15 folders. And that's for one character with one outfit.

I think having the option to assign keep token values per file would be extremely helpful. I'm not sure about the syntax though. I was initially thinking about assigning the value in the name of the file similar to how repeats are done, but since there's an image file associated with the txt, it might be annoying to have to change 2 file names.

kohya-ss commented 1 year ago

Thanks for the suggestion. I understand the situation. It is true that it is complicated to split folders.

There may be a way to solve the problem by defining a special delimiter, such as ; as a marker that keeps up to its location.

However, to achieve this functionality, I would need to extend the processing of the dataset and change the caption processing for each image, which would be somewhat time-consuming. Please deal with this issue by dividing the data into folders for the time being.

If there are many requests for this feature, I will respond to it sooner.

KitsunekoFi commented 1 year ago

Has this feature been implemented yet?