aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/shared.py1
-rw-r--r--modules/textual_inversion/dataset.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/modules/shared.py b/modules/shared.py
index 70b998ff..89f4d5ee 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -321,6 +321,7 @@ options_templates.update(options_section(('system', "System"), {
options_templates.update(options_section(('training', "Training"), {
"unload_models_when_training": OptionInfo(False, "Move VAE and CLIP to RAM when training if possible. Saves VRAM."),
+ "shuffle_tags": OptionInfo(False, "Shuffleing tags by "," when create texts."),
"save_optimizer_state": OptionInfo(False, "Saves Optimizer state as separate *.optim file. Training can be resumed with HN itself and matching optim file."),
"dataset_filename_word_regex": OptionInfo("", "Filename word regex"),
"dataset_filename_join_string": OptionInfo(" ", "Filename join string"),
diff --git a/modules/textual_inversion/dataset.py b/modules/textual_inversion/dataset.py
index ad726577..df278dc2 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)
+ if shared.opts.shuffle_tags:
+ tags = filename_text.split(',')
+ random.shuffle(tags)
+ text = text.replace("[filewords]", ','.join(tags))
+ else:
+ text = text.replace("[filewords]", filename_text)
return text
def __len__(self):