Skip to content

Instantly share code, notes, and snippets.

Forked from camenduru/
Last active October 25, 2022 01:58
What would you like to do?
import math
import os
import sys
import traceback
import modules.scripts as scripts
import gradio as gr
from modules.processing import Processed, process_images, fix_seed
class Script(scripts.Script):
def title(self):
return "Run N times - Seed(+1)"
def ui(self, is_img2img):
n = gr.Textbox(label="n", value="3")
no_save_grid = gr.Checkbox(label="Do not save grid", value=True)
return [n, no_save_grid]
def run(self, p, n, no_save_grid):
loop = int(n)
print(f"Prompt matrix will create {loop} images using a total of {p.n_iter} batches.")
original_prompt = p.prompt[0] if type(p.prompt) == list else p.prompt
p.prompt = [original_prompt] * loop
p.prompt_for_display = original_prompt
p.n_iter = math.ceil(loop / p.batch_size)
p.do_not_save_grid = no_save_grid
return process_images(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment