option to add prompt matrix variable text parts to start of the prompt rather than the end
This commit is contained in:
parent
c9579b51a6
commit
5e83e7081a
15
webui.py
15
webui.py
|
@ -90,6 +90,7 @@ class Options:
|
||||||
"jpeg_quality": (80, "Quality for saved jpeg images", 1, 100),
|
"jpeg_quality": (80, "Quality for saved jpeg images", 1, 100),
|
||||||
"verify_input": (True, "Check input, and produce warning if it's too long"),
|
"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"),
|
"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):
|
def __init__(self):
|
||||||
|
@ -107,6 +108,9 @@ class Options:
|
||||||
if item in self.data:
|
if item in self.data:
|
||||||
return self.data[item]
|
return self.data[item]
|
||||||
|
|
||||||
|
if item in self.data_labels:
|
||||||
|
return self.data_labels[item][0]
|
||||||
|
|
||||||
return super(Options, self).__getattribute__(item)
|
return super(Options, self).__getattribute__(item)
|
||||||
|
|
||||||
def save(self, filename):
|
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("|")
|
prompt_matrix_parts = prompt.split("|")
|
||||||
combination_count = 2 ** (len(prompt_matrix_parts) - 1)
|
combination_count = 2 ** (len(prompt_matrix_parts) - 1)
|
||||||
for combination_num in range(combination_count):
|
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<<n)]
|
||||||
|
|
||||||
for n, text in enumerate(prompt_matrix_parts[1:]):
|
if opts.prompt_matrix_add_to_start:
|
||||||
if combination_num & (2 ** n) > 0:
|
selected_prompts = selected_prompts + [prompt_matrix_parts[0]]
|
||||||
current += ("" if text.strip().startswith(",") else ", ") + text
|
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)
|
n_iter = math.ceil(len(all_prompts) / batch_size)
|
||||||
all_seeds = len(all_prompts) * [seed]
|
all_seeds = len(all_prompts) * [seed]
|
||||||
|
|
Loading…
Reference in New Issue