diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-11-06 08:27:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 08:27:54 +0000 |
commit | 07d1bd426722b4c53b38ff682c5aab53177d8530 (patch) | |
tree | 4fdad803a4536cec2bd3e622c5f4cfb980f04550 /scripts/prompts_from_file.py | |
parent | 3f3d14afd5abd07d3843370dc1c28be299dbdbab (diff) | |
parent | 6e4de5b4422dfc0d45063b2c8c78b19f00321615 (diff) | |
download | stable-diffusion-webui-gfx803-07d1bd426722b4c53b38ff682c5aab53177d8530.tar.gz stable-diffusion-webui-gfx803-07d1bd426722b4c53b38ff682c5aab53177d8530.tar.bz2 stable-diffusion-webui-gfx803-07d1bd426722b4c53b38ff682c5aab53177d8530.zip |
Merge branch 'master' into roy.add_simple_interrogate_api
Diffstat (limited to 'scripts/prompts_from_file.py')
-rw-r--r-- | scripts/prompts_from_file.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/scripts/prompts_from_file.py b/scripts/prompts_from_file.py index 1be22960..3388bc77 100644 --- a/scripts/prompts_from_file.py +++ b/scripts/prompts_from_file.py @@ -83,19 +83,21 @@ def cmdargs(line): def load_prompt_file(file):
- if (file is None):
+ if file is None:
lines = []
else:
lines = [x.strip() for x in file.decode('utf8', errors='ignore').split("\n")]
return None, "\n".join(lines), gr.update(lines=7)
+
class Script(scripts.Script):
def title(self):
return "Prompts from file or textbox"
def ui(self, is_img2img):
checkbox_iterate = gr.Checkbox(label="Iterate seed every line", value=False)
+ checkbox_iterate_batch = gr.Checkbox(label="Use same random seed for all lines", value=False)
prompt_txt = gr.Textbox(label="List of prompt inputs", lines=1)
file = gr.File(label="Upload prompt inputs", type='bytes')
@@ -106,9 +108,9 @@ class Script(scripts.Script): # We don't shrink back to 1, because that causes the control to ignore [enter], and it may
# be unclear to the user that shift-enter is needed.
prompt_txt.change(lambda tb: gr.update(lines=7) if ("\n" in tb) else gr.update(lines=2), inputs=[prompt_txt], outputs=[prompt_txt])
- return [checkbox_iterate, file, prompt_txt]
+ return [checkbox_iterate, checkbox_iterate_batch, prompt_txt]
- def run(self, p, checkbox_iterate, file, prompt_txt: str):
+ def run(self, p, checkbox_iterate, checkbox_iterate_batch, prompt_txt: str):
lines = [x.strip() for x in prompt_txt.splitlines()]
lines = [x for x in lines if len(x) > 0]
@@ -137,7 +139,7 @@ class Script(scripts.Script): jobs.append(args)
print(f"Will process {len(lines)} lines in {job_count} jobs.")
- if (checkbox_iterate and p.seed == -1):
+ if (checkbox_iterate or checkbox_iterate_batch) and p.seed == -1:
p.seed = int(random.randrange(4294967294))
state.job_count = job_count
@@ -153,8 +155,7 @@ class Script(scripts.Script): proc = process_images(copy_p)
images += proc.images
- if (checkbox_iterate):
+ if checkbox_iterate:
p.seed = p.seed + (p.batch_size * p.n_iter)
-
- return Processed(p, images, p.seed, "")
\ No newline at end of file + return Processed(p, images, p.seed, "")
|