Fix to XY_Grid script console progress bar and other progress bar improvements (#890)

Fix to XY_Grid script console progress bar and other progress bar improvements #890
This commit is contained in:
RnDMonkey 2022-09-23 22:09:59 -07:00 committed by GitHub
parent 7aec029423
commit ed8b8b3b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 5 deletions

View File

@ -338,7 +338,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
comments[comment] = 1 comments[comment] = 1
if p.n_iter > 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) samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength)
if state.interrupted: if state.interrupted:

View File

@ -307,6 +307,13 @@ class TotalTQDM:
self.reset() self.reset()
self._tqdm.update() 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): def clear(self):
if self._tqdm is not None: if self._tqdm is not None:
self._tqdm.close() self._tqdm.close()

View File

@ -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 iy, y in enumerate(ys):
for ix, x in enumerate(xs): 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) processed = cell(x, y)
if first_pocessed is None: if first_pocessed is None:
@ -141,10 +141,11 @@ class Script(scripts.Script):
y_values = gr.Textbox(label="Y values", visible=False, lines=1) y_values = gr.Textbox(label="Y values", visible=False, lines=1)
draw_legend = gr.Checkbox(label='Draw legend', value=True) draw_legend = gr.Checkbox(label='Draw legend', value=True)
fixed_seeds = gr.Checkbox(label='Resolve random seeds before plotting (only applies when plotting "-1" seed values for X or Y axis)', value=False)
return [x_type, x_values, y_type, y_values, draw_legend]
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) modules.processing.fix_seed(p)
p.batch_size = 1 p.batch_size = 1
@ -207,6 +208,29 @@ class Script(scripts.Script):
y_opt = axis_options[y_type] y_opt = axis_options[y_type]
ys = process_axis(y_opt, y_values) 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): def cell(x, y):
pc = copy(p) pc = copy(p)
x_opt.apply(pc, x, xs) x_opt.apply(pc, x, xs)