From f1b6ac64e451036fb4dfabe66d79488c56c06776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kyu=E2=99=A5?= <3ad4gum@gmail.com> Date: Wed, 2 Nov 2022 17:24:42 +0100 Subject: Added option to preview Created images on batch completion. --- modules/shared.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'modules/shared.py') diff --git a/modules/shared.py b/modules/shared.py index d8e99f85..d4cf32a4 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -146,6 +146,9 @@ class State: self.interrupted = True def nextjob(self): + if opts.show_progress_every_n_steps == -1: + self.do_set_current_image() + self.job_no += 1 self.sampling_step = 0 self.current_image_sampling_step = 0 @@ -186,17 +189,21 @@ class State: """sets self.current_image from self.current_latent if enough sampling steps have been made after the last call to this""" def set_current_image(self): + if self.sampling_step - self.current_image_sampling_step >= opts.show_progress_every_n_steps and opts.show_progress_every_n_steps > 0: + self.do_set_current_image() + + def do_set_current_image(self): if not parallel_processing_allowed: return + if self.current_latent is None: + return + + if opts.show_progress_grid: + self.current_image = sd_samplers.samples_to_image_grid(self.current_latent) + else: + self.current_image = sd_samplers.sample_to_image(self.current_latent) - if self.sampling_step - self.current_image_sampling_step >= opts.show_progress_every_n_steps and self.current_latent is not None: - if opts.show_progress_grid: - self.current_image = sd_samplers.samples_to_image_grid(self.current_latent) - else: - self.current_image = sd_samplers.sample_to_image(self.current_latent) - - self.current_image_sampling_step = self.sampling_step - + self.current_image_sampling_step = self.sampling_step state = State() @@ -351,7 +358,7 @@ options_templates.update(options_section(('interrogate', "Interrogate Options"), options_templates.update(options_section(('ui', "User interface"), { "show_progressbar": OptionInfo(True, "Show progressbar"), - "show_progress_every_n_steps": OptionInfo(0, "Show image creation progress every N sampling steps. Set 0 to disable.", gr.Slider, {"minimum": 0, "maximum": 32, "step": 1}), + "show_progress_every_n_steps": OptionInfo(0, "Show image creation progress every N sampling steps. Set to 0 to disable. Set to -1 to show after completion of batch.", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}), "show_progress_grid": OptionInfo(True, "Show previews of all images generated in a batch as a grid"), "return_grid": OptionInfo(True, "Show grid in results for web"), "do_not_show_images": OptionInfo(False, "Do not show any images in results for web"), -- cgit v1.2.3 From f2b69709eaff88fc3a2bd49585556ec0883bf5ea Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 4 Nov 2022 09:42:25 +0300 Subject: move option access checking to options class out of various places scattered through code --- modules/shared.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/shared.py') diff --git a/modules/shared.py b/modules/shared.py index d8e99f85..024c771a 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -396,6 +396,15 @@ class Options: def __setattr__(self, key, value): if self.data is not None: if key in self.data or key in self.data_labels: + assert not cmd_opts.freeze_settings, "changing settings is disabled" + + comp_args = opts.data_labels[key].component_args + if isinstance(comp_args, dict) and comp_args.get('visible', True) is False: + raise RuntimeError(f"not possible to set {key} because it is restricted") + + if cmd_opts.hide_ui_dir_config and key in restricted_opts: + raise RuntimeError(f"not possible to set {key} because it is restricted") + self.data[key] = value return @@ -412,6 +421,8 @@ class Options: return super(Options, self).__getattribute__(item) def save(self, filename): + assert not cmd_opts.freeze_settings, "saving settings is disabled" + with open(filename, "w", encoding="utf8") as file: json.dump(self.data, file, indent=4) -- cgit v1.2.3 From ccf1a15412ef6b518f9f54cc26a0ee5edf458108 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 4 Nov 2022 10:16:19 +0300 Subject: add an option to enable installing extensions with --listen or --share --- modules/shared.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/shared.py') diff --git a/modules/shared.py b/modules/shared.py index 024c771a..0a39cdf2 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -44,6 +44,7 @@ parser.add_argument("--precision", type=str, help="evaluate at this precision", parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site") parser.add_argument("--ngrok", type=str, help="ngrok authtoken, alternative to gradio --share", default=None) parser.add_argument("--ngrok-region", type=str, help="The region in which ngrok should start.", default="us") +parser.add_argument("--enable-insecure-extension-access", action='store_true', help="enable extensions tab regardless of other options") parser.add_argument("--codeformer-models-path", type=str, help="Path to directory with codeformer model file(s).", default=os.path.join(models_path, 'Codeformer')) parser.add_argument("--gfpgan-models-path", type=str, help="Path to directory with GFPGAN model file(s).", default=os.path.join(models_path, 'GFPGAN')) parser.add_argument("--esrgan-models-path", type=str, help="Path to directory with ESRGAN model file(s).", default=os.path.join(models_path, 'ESRGAN')) @@ -99,7 +100,7 @@ restricted_opts = { "outdir_save", } -cmd_opts.disable_extension_access = cmd_opts.share or cmd_opts.listen +cmd_opts.disable_extension_access = (cmd_opts.share or cmd_opts.listen) and not cmd_opts.enable_insecure_extension_access devices.device, devices.device_interrogate, devices.device_gfpgan, devices.device_swinir, devices.device_esrgan, devices.device_scunet, devices.device_codeformer = \ (devices.cpu if any(y in cmd_opts.use_cpu for y in [x, 'all']) else devices.get_optimal_device() for x in ['sd', 'interrogate', 'gfpgan', 'swinir', 'esrgan', 'scunet', 'codeformer']) -- cgit v1.2.3