Upload run_n_times.py
Browse files- run_n_times.py +24 -0
run_n_times.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
import traceback
|
| 5 |
+
|
| 6 |
+
import modules.scripts as scripts
|
| 7 |
+
import gradio as gr
|
| 8 |
+
|
| 9 |
+
from modules.processing import Processed, process_images
|
| 10 |
+
|
| 11 |
+
class Script(scripts.Script):
|
| 12 |
+
def title(self):
|
| 13 |
+
return "Batch run (random seed)"
|
| 14 |
+
|
| 15 |
+
def ui(self, is_img2img):
|
| 16 |
+
n = gr.Textbox(label="Batch size")
|
| 17 |
+
return [n]
|
| 18 |
+
|
| 19 |
+
def run(self, p, n):
|
| 20 |
+
for x in range(int(n)):
|
| 21 |
+
p.seed = -1
|
| 22 |
+
proc = process_images(p)
|
| 23 |
+
image = proc.images
|
| 24 |
+
return Processed(p, image, p.seed, proc.info)
|