From 1846ad36a3bd2a60bc9dc59a60e16d3ca7a559fe Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Tue, 23 May 2023 10:58:57 +0800 Subject: Use settings instead of main interface --- modules/generation_parameters_copypaste.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index d5f0a49b..c92fb0fb 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -318,6 +318,11 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), + ('Enable Custom KDiffusion Schedule', 'custom_k_sched'), + ('KDiffusion Scheduler Type', 'k_sched_type'), + ('KDiffusion Scheduler sigma_max', 'sigma_max'), + ('KDiffusion Scheduler sigma_min', 'sigma_min'), + ('KDiffusion Scheduler rho', 'rho'), ('Noise multiplier', 'initial_noise_multiplier'), ('Eta', 'eta_ancestral'), ('Eta DDIM', 'eta_ddim'), -- cgit v1.2.1 From 72377b02518f96051a01a7e0ea30a6a14d8ec1de Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Tue, 23 May 2023 23:48:23 +0800 Subject: Use type to determine if it is enable --- modules/generation_parameters_copypaste.py | 1 - 1 file changed, 1 deletion(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index c92fb0fb..e98866fc 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -318,7 +318,6 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), - ('Enable Custom KDiffusion Schedule', 'custom_k_sched'), ('KDiffusion Scheduler Type', 'k_sched_type'), ('KDiffusion Scheduler sigma_max', 'sigma_max'), ('KDiffusion Scheduler sigma_min', 'sigma_min'), -- cgit v1.2.1 From 4b88e24ebe776680b327e33fe96d7fcf38e2e5d2 Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Wed, 24 May 2023 20:35:58 +0800 Subject: improvements See: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/10649#issuecomment-1561047723 --- modules/generation_parameters_copypaste.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index e98866fc..4f827a6f 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -306,6 +306,18 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model if "RNG" not in res: res["RNG"] = "GPU" + if "KDiff Sched Type" not in res: + res["KDiff Sched Type"] = "Automatic" + + if "KDiff Sched max sigma" not in res: + res["KDiff Sched max sigma"] = 14.6 + + if "KDiff Sched min sigma" not in res: + res["KDiff Sched min sigma"] = 0.3 + + if "KDiff Sched rho" not in res: + res["KDiff Sched rho"] = 7.0 + return res @@ -318,10 +330,10 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), - ('KDiffusion Scheduler Type', 'k_sched_type'), - ('KDiffusion Scheduler sigma_max', 'sigma_max'), - ('KDiffusion Scheduler sigma_min', 'sigma_min'), - ('KDiffusion Scheduler rho', 'rho'), + ('KDiff Sched Type', 'k_sched_type'), + ('KDiff Sched max sigma', 'sigma_max'), + ('KDiff Sched min sigma', 'sigma_min'), + ('KDiff Sched rho', 'rho'), ('Noise multiplier', 'initial_noise_multiplier'), ('Eta', 'eta_ancestral'), ('Eta DDIM', 'eta_ddim'), -- cgit v1.2.1 From a69b71a37f1fd32a60fbd87beed13f4f280400bd Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Wed, 24 May 2023 20:40:37 +0800 Subject: use Schedule instead of Sched --- modules/generation_parameters_copypaste.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 4f827a6f..1443c5cd 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -306,17 +306,17 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model if "RNG" not in res: res["RNG"] = "GPU" - if "KDiff Sched Type" not in res: - res["KDiff Sched Type"] = "Automatic" + if "KDiff Schedule Type" not in res: + res["KDiff Schedule Type"] = "Automatic" - if "KDiff Sched max sigma" not in res: - res["KDiff Sched max sigma"] = 14.6 + if "KDiff Schedule max sigma" not in res: + res["KDiff Schedule max sigma"] = 14.6 - if "KDiff Sched min sigma" not in res: - res["KDiff Sched min sigma"] = 0.3 + if "KDiff Schedule min sigma" not in res: + res["KDiff Schedule min sigma"] = 0.3 - if "KDiff Sched rho" not in res: - res["KDiff Sched rho"] = 7.0 + if "KDiff Schedule rho" not in res: + res["KDiff Schedule rho"] = 7.0 return res @@ -330,10 +330,10 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), - ('KDiff Sched Type', 'k_sched_type'), - ('KDiff Sched max sigma', 'sigma_max'), - ('KDiff Sched min sigma', 'sigma_min'), - ('KDiff Sched rho', 'rho'), + ('KDiff Schedule Type', 'k_sched_type'), + ('KDiff Schedule max sigma', 'sigma_max'), + ('KDiff Schedule min sigma', 'sigma_min'), + ('KDiff Schedule rho', 'rho'), ('Noise multiplier', 'initial_noise_multiplier'), ('Eta', 'eta_ancestral'), ('Eta DDIM', 'eta_ddim'), -- cgit v1.2.1 From e8e7fe11e903115a706187f8301df2e06fa018f8 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sat, 27 May 2023 19:53:09 +0300 Subject: updates for the noise schedule settings --- modules/generation_parameters_copypaste.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 1443c5cd..81aef502 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -306,17 +306,17 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model if "RNG" not in res: res["RNG"] = "GPU" - if "KDiff Schedule Type" not in res: - res["KDiff Schedule Type"] = "Automatic" + if "Schedule type" not in res: + res["Schedule type"] = "Automatic" - if "KDiff Schedule max sigma" not in res: - res["KDiff Schedule max sigma"] = 14.6 + if "Schedule max sigma" not in res: + res["Schedule max sigma"] = 0 - if "KDiff Schedule min sigma" not in res: - res["KDiff Schedule min sigma"] = 0.3 + if "Schedule min sigma" not in res: + res["Schedule min sigma"] = 0 - if "KDiff Schedule rho" not in res: - res["KDiff Schedule rho"] = 7.0 + if "Schedule rho" not in res: + res["Schedule rho"] = 0 return res @@ -330,10 +330,10 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), - ('KDiff Schedule Type', 'k_sched_type'), - ('KDiff Schedule max sigma', 'sigma_max'), - ('KDiff Schedule min sigma', 'sigma_min'), - ('KDiff Schedule rho', 'rho'), + ('Schedule type', 'k_sched_type'), + ('Schedule max sigma', 'sigma_max'), + ('Schedule min sigma', 'sigma_min'), + ('Schedule rho', 'rho'), ('Noise multiplier', 'initial_noise_multiplier'), ('Eta', 'eta_ancestral'), ('Eta DDIM', 'eta_ddim'), -- cgit v1.2.1 From b957dcfece29c84ac0cfcd5a69475ff8684c531f Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 28 May 2023 10:39:57 +0300 Subject: add quoting for infotext values that have a colon in them --- modules/generation_parameters_copypaste.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 81aef502..071bd9ea 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -35,7 +35,7 @@ def reset(): def quote(text): - if ',' not in str(text) and '\n' not in str(text): + if ',' not in str(text) and '\n' not in str(text) and ':' not in str(text): return text return json.dumps(text, ensure_ascii=False) -- cgit v1.2.1 From 51864790fd72386fbbbb015d24a43ce501ecaa4b Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 2 Jun 2023 14:58:10 +0300 Subject: Simplify a bunch of `len(x) > 0`/`len(x) == 0` style expressions --- modules/generation_parameters_copypaste.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 071bd9ea..237401a1 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -55,7 +55,7 @@ def image_from_url_text(filedata): if filedata is None: return None - if type(filedata) == list and len(filedata) > 0 and type(filedata[0]) == dict and filedata[0].get("is_file", False): + if type(filedata) == list and filedata and type(filedata[0]) == dict and filedata[0].get("is_file", False): filedata = filedata[0] if type(filedata) == dict and filedata.get("is_file", False): @@ -437,7 +437,7 @@ def connect_paste(button, paste_fields, input_comp, override_settings_component, vals_pairs = [f"{k}: {v}" for k, v in vals.items()] - return gr.Dropdown.update(value=vals_pairs, choices=vals_pairs, visible=len(vals_pairs) > 0) + return gr.Dropdown.update(value=vals_pairs, choices=vals_pairs, visible=bool(vals_pairs)) paste_fields = paste_fields + [(override_settings_component, paste_settings)] @@ -454,5 +454,3 @@ def connect_paste(button, paste_fields, input_comp, override_settings_component, outputs=[], show_progress=False, ) - - -- cgit v1.2.1 From f98f4f73aa4898c754681f411608df5f248619f6 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 4 Jun 2023 10:56:48 +0300 Subject: infer styles from prompts, and an option to control the behavior --- modules/generation_parameters_copypaste.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 071bd9ea..4c420e5f 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -265,6 +265,14 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model else: prompt += ("" if prompt == "" else "\n") + line + if shared.opts.infotext_styles != "Ignore": + found_styles, prompt, negative_prompt = shared.prompt_styles.extract_styles_from_prompt(prompt, negative_prompt) + + if shared.opts.infotext_styles == "Apply": + res["Styles array"] = found_styles + elif shared.opts.infotext_styles == "Apply if any" and found_styles: + res["Styles array"] = found_styles + res["Prompt"] = prompt res["Negative prompt"] = negative_prompt -- cgit v1.2.1 From ba70a220e3176153ba2a559acb9e5aa692dce7ca Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 5 Jun 2023 22:20:29 +0300 Subject: Remove a bunch of unused/vestigial code As found by Vulture and some eyes --- modules/generation_parameters_copypaste.py | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 1d02ffae..699b1a81 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -174,31 +174,6 @@ def send_image_and_dimensions(x): return img, w, h - -def find_hypernetwork_key(hypernet_name, hypernet_hash=None): - """Determines the config parameter name to use for the hypernet based on the parameters in the infotext. - - Example: an infotext provides "Hypernet: ke-ta" and "Hypernet hash: 1234abcd". For the "Hypernet" config - parameter this means there should be an entry that looks like "ke-ta-10000(1234abcd)" to set it to. - - If the infotext has no hash, then a hypernet with the same name will be selected instead. - """ - hypernet_name = hypernet_name.lower() - if hypernet_hash is not None: - # Try to match the hash in the name - for hypernet_key in shared.hypernetworks.keys(): - result = re_hypernet_hash.search(hypernet_key) - if result is not None and result[1] == hypernet_hash: - return hypernet_key - else: - # Fall back to a hypernet with the same name - for hypernet_key in shared.hypernetworks.keys(): - if hypernet_key.lower().startswith(hypernet_name): - return hypernet_key - - return None - - def restore_old_hires_fix_params(res): """for infotexts that specify old First pass size parameter, convert it into width, height, and hr scale""" @@ -329,10 +304,6 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model return res -settings_map = {} - - - infotext_to_setting_name_mapping = [ ('Clip skip', 'CLIP_stop_at_last_layers', ), ('Conditional mask weight', 'inpainting_mask_weight'), -- cgit v1.2.1 From 851bf43520226da6cfe5f6546d9aaf035a121182 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 6 Jun 2023 05:40:00 +0900 Subject: print error and continue print error and continue --- modules/generation_parameters_copypaste.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index 1d02ffae..a638f912 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -277,15 +277,18 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model res["Negative prompt"] = negative_prompt for k, v in re_param.findall(lastline): - if v[0] == '"' and v[-1] == '"': - v = unquote(v) - - m = re_imagesize.match(v) - if m is not None: - res[f"{k}-1"] = m.group(1) - res[f"{k}-2"] = m.group(2) - else: - res[k] = v + try: + if v[0] == '"' and v[-1] == '"': + v = unquote(v) + + m = re_imagesize.match(v) + if m is not None: + res[f"{k}-1"] = m.group(1) + res[f"{k}-2"] = m.group(2) + else: + res[k] = v + except Exception: + print(f"Error parsing \"{k}: {v}\"") # Missing CLIP skip means it was set to 1 (the default) if "Clip skip" not in res: -- cgit v1.2.1 From 4bd490c28dd8f17b7df943eb3963c34d725084fc Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Tue, 27 Jun 2023 06:18:43 +0300 Subject: add missing infotext entry for the pad cond/uncond option --- modules/generation_parameters_copypaste.py | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/generation_parameters_copypaste.py') diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index a638f912..dd30a1b5 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -357,6 +357,7 @@ infotext_to_setting_name_mapping = [ ('Token merging ratio hr', 'token_merging_ratio_hr'), ('RNG', 'randn_source'), ('NGMS', 's_min_uncond'), + ('Pad conds', 'pad_cond_uncond'), ] -- cgit v1.2.1