From 6981262bebb8731af3a0977caa4e071ca9245ca0 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 25 Apr 2023 19:02:32 -0400 Subject: [PATCH] validate script_args --- .gitignore | 1 + TODO.md | 2 +- extensions-builtin/seed_travel | 2 +- modules/processing.py | 2 -- modules/scripts.py | 11 +++++++++-- modules/txt2img.py | 12 ++---------- modules/ui_extensions.py | 9 +++++---- setup.py | 7 +++---- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 8a9c92f78..13e8eab0c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__ /styles.csv /user.css /webui-user.bat +/webui-user.sh /javascript/themes.json venv diff --git a/TODO.md b/TODO.md index 30e1a89b3..4b379ab9f 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,7 @@ Stuff to be fixed... - Run VAE with hires at 1280 - Transformers version - Move Restart Server from WebUI to Launch and reload modules -- gr.Dropdowns with None selected +- follow-up on `p.script_args` ## Features diff --git a/extensions-builtin/seed_travel b/extensions-builtin/seed_travel index 1a97ebb43..ffe0553c5 160000 --- a/extensions-builtin/seed_travel +++ b/extensions-builtin/seed_travel @@ -1 +1 @@ -Subproject commit 1a97ebb43428b43c41001cfe79e50b468126d99f +Subproject commit ffe0553c59e91067ebf1e4fc7ad85ca9c870bf57 diff --git a/modules/processing.py b/modules/processing.py index a546e4f19..0ce6d4c91 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -154,13 +154,11 @@ class StableDiffusionProcessing: self.override_settings_restore_afterwards = override_settings_restore_afterwards self.is_using_inpainting_conditioning = False self.disable_extra_networks = False - if not seed_enable_extras: self.subseed = -1 self.subseed_strength = 0 self.seed_resize_from_h = 0 self.seed_resize_from_w = 0 - self.scripts = None self.script_args = script_args self.all_prompts = None diff --git a/modules/scripts.py b/modules/scripts.py index da76b22ab..2cc744568 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -2,9 +2,8 @@ import os import re import sys from collections import namedtuple - +from rich import print # pylint: disable=redefined-builtin import gradio as gr - from modules import shared, paths, script_callbacks, extensions, script_loading, scripts_postprocessing, errors AlwaysVisible = object() @@ -418,6 +417,8 @@ class ScriptRunner: def process(self, p): for script in self.alwayson_scripts: try: + if p.script_args[0] == 'enabled': + return script_args = p.script_args[script.args_from:script.args_to] script.process(p, *script_args) except Exception as e: @@ -434,6 +435,8 @@ class ScriptRunner: def process_batch(self, p, **kwargs): for script in self.alwayson_scripts: try: + if p.script_args[0] == 'enabled': + return script_args = p.script_args[script.args_from:script.args_to] script.process_batch(p, *script_args, **kwargs) except Exception as e: @@ -442,6 +445,8 @@ class ScriptRunner: def postprocess(self, p, processed): for script in self.alwayson_scripts: try: + if p.script_args[0] == 'enabled': + return script_args = p.script_args[script.args_from:script.args_to] script.postprocess(p, processed, *script_args) except Exception as e: @@ -450,6 +455,8 @@ class ScriptRunner: def postprocess_batch(self, p, images, **kwargs): for script in self.alwayson_scripts: try: + if p.script_args[0] == 'enabled': + return script_args = p.script_args[script.args_from:script.args_to] script.postprocess_batch(p, *script_args, images=images, **kwargs) except Exception as e: diff --git a/modules/txt2img.py b/modules/txt2img.py index 73fdb1178..70204293b 100644 --- a/modules/txt2img.py +++ b/modules/txt2img.py @@ -1,14 +1,14 @@ import modules.scripts from modules import sd_samplers from modules.generation_parameters_copypaste import create_override_settings_dict -from modules.processing import StableDiffusionProcessing, Processed, StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images +from modules.processing import StableDiffusionProcessingTxt2Img, process_images from modules.shared import opts import modules.shared as shared from modules.ui import plaintext_to_html def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, steps: int, sampler_index: int, restore_faces: bool, tiling: bool, n_iter: int, batch_size: int, cfg_scale: float, seed: int, subseed: int, subseed_strength: float, seed_resize_from_h: int, seed_resize_from_w: int, seed_enable_extras: bool, height: int, width: int, enable_hr: bool, denoising_strength: float, hr_scale: float, hr_upscaler: str, hr_second_pass_steps: int, hr_resize_x: int, hr_resize_y: int, override_settings_texts, *args): - override_settings = create_override_settings_dict(override_settings_texts) + override_settings = create_override_settings_dict(override_settings_texts) # pylint: disable=unused-argument p = StableDiffusionProcessingTxt2Img( sd_model=shared.sd_model, outpath_samples=opts.outdir_samples or opts.outdir_txt2img_samples, @@ -40,22 +40,14 @@ def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, step hr_resize_y=hr_resize_y, override_settings=override_settings, ) - p.scripts = modules.scripts.scripts_txt2img p.script_args = args - processed = modules.scripts.scripts_txt2img.run(p, *args) - if processed is None: processed = process_images(p) - p.close() - shared.total_tqdm.clear() - generation_info_js = processed.js() - if opts.do_not_show_images: processed.images = [] - return processed.images, generation_info_js, plaintext_to_html(processed.info), plaintext_to_html(processed.comments) diff --git a/modules/ui_extensions.py b/modules/ui_extensions.py index da51af8e8..66754f58c 100644 --- a/modules/ui_extensions.py +++ b/modules/ui_extensions.py @@ -43,9 +43,10 @@ def apply_and_restart(disable_list, update_list, disable_all): shared.opts.disable_all_extensions = disable_all shared.opts.save(shared.config_filename) - shared.state.interrupt() - shared.state.need_restart = True - shared.restart_server() + # shared.state.interrupt() + # shared.state.need_restart = True + # shared.restart_server() + print('Extension list updated - please restart the server') def check_updates(_id_task, disable_list): @@ -292,7 +293,7 @@ def create_ui(): with gr.TabItem("Installed"): with gr.Row(elem_id="extensions_installed_top"): - apply = gr.Button(value="Apply & restart UI", variant="primary") + apply = gr.Button(value="Apply (restart required)", variant="primary") check = gr.Button(value="Check for updates") extensions_disable_all = gr.Radio(label="Disable all extensions", choices=["none", "extra", "all"], value=shared.opts.disable_all_extensions, elem_id="extensions_disable_all") extensions_disabled_list = gr.Text(elem_id="extensions_disabled_list", visible=False).style(container=False) diff --git a/setup.py b/setup.py index a9499dc6b..0ce3a052a 100644 --- a/setup.py +++ b/setup.py @@ -135,14 +135,13 @@ def update(folder): return branch = git('branch', folder) if 'main' in branch: - git('checkout main', folder) branch = 'main' elif 'master' in branch: - git('checkout master', folder) branch = 'master' else: - log.warning(f'Unknown branch for: {folder}') - branch = None + branch = branch.split('\n')[0].replace('*', '').strip() + log.debug(f'Setting branch: {folder} / {branch}') + git(f'checkout {branch}', folder) if branch is None: git('pull --autostash --rebase', folder) else: