From 60bd4fba037d9f304cac6d275b9cad6abf66308a Mon Sep 17 00:00:00 2001 From: Pazz Date: Tue, 1 Aug 2023 18:03:21 +0200 Subject: [PATCH 1/3] fix: progress-bar update when doing batches --- scripts/onebuttonprompt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 3b816ea..95c522f 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -987,8 +987,8 @@ class Script(scripts.Script): # prefixprompt = "" - - + state.job_count = batches + for i in range(batches): if(silentmode == False): @@ -1067,6 +1067,9 @@ class Script(scripts.Script): p.seed += 1 p.seed +=1 + + state.job = f"{state.job_no} out of {state.job_count}" + # just return all the things p.n_iter = 0 p.batch_size = 0 From ee1fec03ff4f16466196e3aa35f8fde247e92f96 Mon Sep 17 00:00:00 2001 From: Pazz Date: Tue, 1 Aug 2023 18:05:14 +0200 Subject: [PATCH 2/3] fix: generation of random seed When -1 is selected, a random seed is generated which is increased by 'batch_size' for every 'batch_count'. When a seed is specified, this seed will be reused as start for every 'batch_count'. --- scripts/onebuttonprompt.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 95c522f..2ddec0d 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -970,6 +970,9 @@ class Script(scripts.Script): p.n_iter = 1 p.batch_size = 1 + initialseed = p.seed + if p.seed == -1: + p.seed = int(random.randrange(4294967294)) if(silentmode and workprompt != ""): print("Workflow mode turned on, not generating a prompt. Using workflow prompt.") @@ -1061,15 +1064,14 @@ class Script(scripts.Script): infotexts += processed.infotexts all_seeds.append(processed.seed) all_prompts.append(processed.prompt) - - # Only move up a seed, when there are multiple batchsizes, and we had the first one done. - if(initialbatchsize != 1): - p.seed += 1 - p.seed +=1 state.job = f"{state.job_no} out of {state.job_count}" + # Increase seed by batchsize for unique seeds for every picture if -1 was chosen + if initialseed == -1: + p.seed += batchsize + # just return all the things p.n_iter = 0 p.batch_size = 0 From 43509333ec2a09cfbab3ccf3a9a9339fb809912d Mon Sep 17 00:00:00 2001 From: Pazz Date: Tue, 1 Aug 2023 18:06:25 +0200 Subject: [PATCH 3/3] fix: save images from ui when a batch was run When doing batches, it was not possible to save images from the ui because the prompts and images sent to the ui didn't align. --- scripts/onebuttonprompt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 2ddec0d..5f09eba 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -1062,9 +1062,14 @@ class Script(scripts.Script): processed = process_images(p) images += processed.images infotexts += processed.infotexts + + # prompt and seed info for batch grid all_seeds.append(processed.seed) all_prompts.append(processed.prompt) + # prompt and seed info for individual images + all_seeds += processed.all_seeds + all_prompts += processed.all_prompts state.job = f"{state.job_no} out of {state.job_count}"