Skip to content

Commit 315bd7c

Browse files
author
Keith Dreibelbis
committed
prompts_from_file: allow random seeds to be preserved for the list of prompts
1 parent 2192b64 commit 315bd7c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/prompts_from_file.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def title(self):
9696

9797
def ui(self, is_img2img):
9898
checkbox_iterate = gr.Checkbox(label="Iterate seed every line", value=False)
99+
checkbox_iterate_batch = gr.Checkbox(label="Preserve random seed across lines (for use with \"Generate Forever\")", value=False)
99100

100101
prompt_txt = gr.Textbox(label="List of prompt inputs", lines=1)
101102
file = gr.File(label="Upload prompt inputs", type='bytes')
@@ -106,9 +107,9 @@ def ui(self, is_img2img):
106107
# We don't shrink back to 1, because that causes the control to ignore [enter], and it may
107108
# be unclear to the user that shift-enter is needed.
108109
prompt_txt.change(lambda tb: gr.update(lines=7) if ("\n" in tb) else gr.update(lines=2), inputs=[prompt_txt], outputs=[prompt_txt])
109-
return [checkbox_iterate, file, prompt_txt]
110+
return [checkbox_iterate, checkbox_iterate_batch, file, prompt_txt]
110111

111-
def run(self, p, checkbox_iterate, file, prompt_txt: str):
112+
def run(self, p, checkbox_iterate, checkbox_iterate_batch, file, prompt_txt: str):
112113
lines = [x.strip() for x in prompt_txt.splitlines()]
113114
lines = [x for x in lines if len(x) > 0]
114115

@@ -137,7 +138,7 @@ def run(self, p, checkbox_iterate, file, prompt_txt: str):
137138
jobs.append(args)
138139

139140
print(f"Will process {len(lines)} lines in {job_count} jobs.")
140-
if (checkbox_iterate and p.seed == -1):
141+
if ((checkbox_iterate or checkbox_iterate_batch) and p.seed == -1):
141142
p.seed = int(random.randrange(4294967294))
142143

143144
state.job_count = job_count

0 commit comments

Comments
 (0)