Merge pull request #4117 from TinkTheBoush/master

Adding optional tag shuffling for training
This commit is contained in:
AUTOMATIC1111
2022-11-11 15:46:20 +03:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -98,7 +98,12 @@ class PersonalizedBase(Dataset):
def create_text(self, filename_text):
text = random.choice(self.lines)
text = text.replace("[name]", self.placeholder_token)
text = text.replace("[filewords]", filename_text)
tags = filename_text.split(',')
if shared.opts.tag_drop_out != 0:
tags = [t for t in tags if random.random() > shared.opts.tag_drop_out]
if shared.opts.shuffle_tags:
random.shuffle(tags)
text = text.replace("[filewords]", ','.join(tags))
return text
def __len__(self):