| 112 | return "Prompts from file or textbox" |
| 113 | |
| 114 | def ui(self, is_img2img): |
| 115 | checkbox_iterate = gr.Checkbox(label="Iterate seed every line", value=False, elem_id=self.elem_id("checkbox_iterate")) |
| 116 | checkbox_iterate_batch = gr.Checkbox(label="Use same random seed for all lines", value=False, elem_id=self.elem_id("checkbox_iterate_batch")) |
| 117 | prompt_position = gr.Radio(["start", "end"], label="Insert prompts at the", elem_id=self.elem_id("prompt_position"), value="start") |
| 118 | |
| 119 | prompt_txt = gr.Textbox(label="List of prompt inputs", lines=1, elem_id=self.elem_id("prompt_txt")) |
| 120 | file = gr.File(label="Upload prompt inputs", type='binary', elem_id=self.elem_id("file")) |
| 121 | |
| 122 | file.change(fn=load_prompt_file, inputs=[file], outputs=[file, prompt_txt, prompt_txt], show_progress=False) |
| 123 | |
| 124 | # We start at one line. When the text changes, we jump to seven lines, or two lines if no \n. |
| 125 | # We don't shrink back to 1, because that causes the control to ignore [enter], and it may |
| 126 | # be unclear to the user that shift-enter is needed. |
| 127 | prompt_txt.change(lambda tb: gr.update(lines=7) if ("\n" in tb) else gr.update(lines=2), inputs=[prompt_txt], outputs=[prompt_txt], show_progress=False) |
| 128 | return [checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt] |
| 129 | |
| 130 | def run(self, p, checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt: str): |
| 131 | lines = [x for x in (x.strip() for x in prompt_txt.splitlines()) if x] |