diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-11-11 12:46:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 12:46:20 +0000 |
commit | 73776907ec460747f37e1154d890a44fd83b8440 (patch) | |
tree | 56540e2a47ae664a810f6e19ad6451f03c2dbc58 /modules/textual_inversion/dataset.py | |
parent | 6585cba20048576ebac8613c34c01dd85c894b86 (diff) | |
parent | a1e271207dfc3e89b1286ba41d96b459f210c4b2 (diff) | |
download | stable-diffusion-webui-gfx803-73776907ec460747f37e1154d890a44fd83b8440.tar.gz stable-diffusion-webui-gfx803-73776907ec460747f37e1154d890a44fd83b8440.tar.bz2 stable-diffusion-webui-gfx803-73776907ec460747f37e1154d890a44fd83b8440.zip |
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.py | 7 |
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):
|