aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/processing.py2
-rw-r--r--modules/shared.py7
-rw-r--r--scripts/xy_grid.py32
3 files changed, 36 insertions, 5 deletions
diff --git a/modules/processing.py b/modules/processing.py
index 0246e094..a899566d 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -338,7 +338,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
comments[comment] = 1
if p.n_iter > 1:
- shared.state.job = f"Batch {n+1} out of {p.n_iter}"
+ shared.state.job = f"Image {n+1} out of {p.n_iter}; Batch {(shared.state.job_no // p.n_iter) + 1} of {shared.state.job_count // p.n_iter}"
samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength)
if state.interrupted:
diff --git a/modules/shared.py b/modules/shared.py
index 667c3441..7bad7a6d 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -307,6 +307,13 @@ class TotalTQDM:
self.reset()
self._tqdm.update()
+ def updateTotal(self, new_total):
+ if not opts.multiple_tqdm:
+ return
+ if self._tqdm is None:
+ self.reset()
+ self._tqdm.total=new_total
+
def clear(self):
if self._tqdm is not None:
self._tqdm.close()
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
index 6a157722..cb1312ae 100644
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -102,7 +102,7 @@ def draw_xy_grid(p, xs, ys, x_labels, y_labels, cell, draw_legend):
for iy, y in enumerate(ys):
for ix, x in enumerate(xs):
- state.job = f"{ix + iy * len(xs) + 1} out of {len(xs) * len(ys)}"
+ state.job = f"Image {ix + iy * len(xs) + 1} out of {state.job_count}"
processed = cell(x, y)
if first_pocessed is None:
@@ -141,10 +141,11 @@ class Script(scripts.Script):
y_values = gr.Textbox(label="Y values", visible=False, lines=1)
draw_legend = gr.Checkbox(label='Draw legend', value=True)
-
- return [x_type, x_values, y_type, y_values, draw_legend]
+ fixed_seeds = gr.Checkbox(label='Resolve random seeds before plotting (only applies when plotting "-1" seed values for X or Y axis)', value=False)
- def run(self, p, x_type, x_values, y_type, y_values, draw_legend):
+ return [x_type, x_values, y_type, y_values, draw_legend, fixed_seeds]
+
+ def run(self, p, x_type, x_values, y_type, y_values, draw_legend, fixed_seeds):
modules.processing.fix_seed(p)
p.batch_size = 1
@@ -207,6 +208,29 @@ class Script(scripts.Script):
y_opt = axis_options[y_type]
ys = process_axis(y_opt, y_values)
+ def fix_axis_seeds(axis_opt, axis_list):
+ if axis_opt.label == 'Seed':
+ return [int(random.randrange(4294967294)) if val is None or val == '' or val == -1 else val for val in axis_list]
+ else:
+ return axis_list
+
+ if fixed_seeds == True:
+ xs = fix_axis_seeds(x_opt, xs)
+ ys = fix_axis_seeds(y_opt, ys)
+
+ if x_opt.label == 'Steps':
+ total_steps = sum(xs) * len(ys)
+ elif y_opt.label == 'Steps':
+ total_steps = sum(ys) * len(xs)
+ else:
+ total_steps = p.steps * len(xs) * len(ys)
+
+ if p.n_iter > 1:
+ print(f"Number of seeds/images per prompt is {p.n_iter}.")
+
+ print(f"X/Y plot will create {len(xs) * len(ys) * p.n_iter} images on a {len(xs)} x {len(ys)} grid. (Total steps to process: {total_steps * p.n_iter})")
+ shared.total_tqdm.updateTotal(total_steps * p.n_iter)
+
def cell(x, y):
pc = copy(p)
x_opt.apply(pc, x, xs)