aboutsummaryrefslogtreecommitdiff
path: root/modules/textual_inversion/dataset.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2022-11-11 15:46:20 +0300
committerGitHub <noreply@github.com>2022-11-11 15:46:20 +0300
commit73776907ec460747f37e1154d890a44fd83b8440 (patch)
tree56540e2a47ae664a810f6e19ad6451f03c2dbc58 /modules/textual_inversion/dataset.py
parent6585cba20048576ebac8613c34c01dd85c894b86 (diff)
parenta1e271207dfc3e89b1286ba41d96b459f210c4b2 (diff)
Merge pull request #4117 from TinkTheBoush/master
Adding optional tag shuffling for training
Diffstat (limited to 'modules/textual_inversion/dataset.py')
-rw-r--r--modules/textual_inversion/dataset.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/textual_inversion/dataset.py b/modules/textual_inversion/dataset.py
index ad726577..eb75c376 100644
--- a/modules/textual_inversion/dataset.py
+++ b/modules/textual_inversion/dataset.py
@@ -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):