From 5e83e7081af938baccec4e8548411107ab261817 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 26 Aug 2022 08:47:44 +0300 Subject: [PATCH] option to add prompt matrix variable text parts to start of the prompt rather than the end --- webui.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/webui.py b/webui.py index 40764178..36c7454d 100644 --- a/webui.py +++ b/webui.py @@ -90,6 +90,7 @@ class Options: "jpeg_quality": (80, "Quality for saved jpeg images", 1, 100), "verify_input": (True, "Check input, and produce warning if it's too long"), "enable_pnginfo": (True, "Save text information about generation parameters as chunks to png files"), + "prompt_matrix_add_to_start": (True, "In prompt matrix, add the variable combination of text to the start of the prompt, rather than the end"), } def __init__(self): @@ -107,6 +108,9 @@ class Options: if item in self.data: return self.data[item] + if item in self.data_labels: + return self.data_labels[item][0] + return super(Options, self).__getattribute__(item) def save(self, filename): @@ -568,13 +572,14 @@ def process_images(outpath, func_init, func_sample, prompt, seed, sampler_index, prompt_matrix_parts = prompt.split("|") combination_count = 2 ** (len(prompt_matrix_parts) - 1) for combination_num in range(combination_count): - current = prompt_matrix_parts[0] + selected_prompts = [text.strip().strip(',') for n, text in enumerate(prompt_matrix_parts[1:]) if combination_num & (1< 0: - current += ("" if text.strip().startswith(",") else ", ") + text + if opts.prompt_matrix_add_to_start: + selected_prompts = selected_prompts + [prompt_matrix_parts[0]] + else: + selected_prompts = [prompt_matrix_parts[0]] + selected_prompts - all_prompts.append(current) + all_prompts.append( ", ".join(selected_prompts)) n_iter = math.ceil(len(all_prompts) / batch_size) all_seeds = len(all_prompts) * [seed]