From d6906c1bb7bb93f35c71b42a8293fcc6e85e1c04 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 14:09:01 -0500 Subject: [PATCH 1/7] update git action --- .github/workflows/on_pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pull_request.yaml b/.github/workflows/on_pull_request.yaml index 546c3a552..7abade093 100644 --- a/.github/workflows/on_pull_request.yaml +++ b/.github/workflows/on_pull_request.yaml @@ -21,7 +21,7 @@ jobs: python -m pip install --upgrade pip pip install pylint - name: pre-commit - uses: pre-commit-ci/lite-action@v1.0.1 + uses: pre-commit-ci/lite-action@v1.0.2 if: always() with: msg: apply code formatting and linting auto-fixes From b63a7d455c7982bed76ec31f9e364486fbffc658 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 20:30:59 -0500 Subject: [PATCH 2/7] fix installer and requirements --- cli/requirements.txt | 3 +++ installer.py | 16 +++++++++++----- modules/postprocess/gfpgan_model.py | 5 ++++- modules/textual_inversion/textual_inversion.py | 2 ++ requirements.txt | 10 +--------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cli/requirements.txt b/cli/requirements.txt index a63adae95..4918412d5 100644 --- a/cli/requirements.txt +++ b/cli/requirements.txt @@ -1,4 +1,7 @@ +aiohttp mediapipe +extcolors colormap filetype albumentations +matplotlib diff --git a/installer.py b/installer.py index a2f857cc9..cfb322cf5 100644 --- a/installer.py +++ b/installer.py @@ -9,7 +9,7 @@ import subprocess import cProfile try: - import pkg_resources # python 3.12 no longer packages it built-in + import pkg_resources # python 3.12 no longer has it built-in except ImportError: stdout = subprocess.run(f'"{sys.executable}" -m pip install setuptools', shell=True, check=False, env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE) import pkg_resources @@ -405,13 +405,16 @@ def check_torch(): log.debug(f'Torch allowed: cuda={allow_cuda} rocm={allow_rocm} ipex={allow_ipex} diml={allow_directml} openvino={allow_openvino}') torch_command = os.environ.get('TORCH_COMMAND', '') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') + def is_rocm_available(): if not allow_rocm: return False if platform.system() == 'Windows': hip_path = os.environ.get('HIP_PATH', None) return hip_path is not None and os.path.exists(os.path.join(hip_path, 'bin')) - return shutil.which('rocminfo') is not None or os.path.exists('/opt/rocm/bin/rocminfo') or os.path.exists('/dev/kfd') + else: + return shutil.which('rocminfo') is not None or os.path.exists('/opt/rocm/bin/rocminfo') or os.path.exists('/dev/kfd') + if torch_command != '': pass elif allow_cuda and (shutil.which('nvidia-smi') is not None or args.use_xformers or os.path.exists(os.path.join(os.environ.get('SystemRoot') or r'C:\Windows', 'System32', 'nvidia-smi.exe'))): @@ -439,7 +442,7 @@ def check_torch(): amd_gpus = [x for x in amd_gpus if x and x != 'gfx000'] log.debug(f'ROCm agents detected: {amd_gpus}') except Exception as e: - log.debug(f'Run rocm_agent_enumerator failed: {e}') + log.debug(f'ROCm agent enumerator failed: {e}') amd_gpus = [] hip_visible_devices = [] # use the first available amd gpu by default @@ -481,6 +484,9 @@ def check_torch(): torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision --index-url https://download.pytorch.org/whl/rocm5.5') if rocm_ver is not None: install(os.environ.get('ONNXRUNTIME_PACKAGE', get_onnxruntime_source_for_rocm(arr)), "onnxruntime-training built with ROCm", ignore=True) + else: + log.info('Using CPU-only Torch') + torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') elif allow_ipex and (args.use_ipex or shutil.which('sycl-ls') is not None or shutil.which('sycl-ls.exe') is not None or os.environ.get('ONEAPI_ROOT') is not None or os.path.exists('/opt/intel/oneapi') or os.path.exists("C:/Program Files (x86)/Intel/oneAPI") or os.path.exists("C:/oneAPI")): args.use_ipex = True # pylint: disable=attribute-defined-outside-init @@ -517,7 +523,7 @@ def check_torch(): log.info('Using OpenVINO') torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu') install(os.environ.get('OPENVINO_PACKAGE', 'openvino==2023.3.0'), 'openvino') - install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) # TODO openvino: numpy version conflicts with tensorflow and doesn't support Python 3.11 + install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) install('nncf==2.8.1', 'nncf') os.environ.setdefault('PYTORCH_TRACING_MODE', 'TORCHFX') os.environ.setdefault('NEOReadDebugKeys', '1') @@ -536,7 +542,7 @@ def check_torch(): log.info('Using CPU-only Torch') torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') if 'torch' in torch_command and not args.version: - # log.info('Installing torch - this may take a while') + log.debug(f'Installing torch: {torch_command}') install(torch_command, 'torch torchvision') else: try: diff --git a/modules/postprocess/gfpgan_model.py b/modules/postprocess/gfpgan_model.py index 98326e378..ee412012d 100644 --- a/modules/postprocess/gfpgan_model.py +++ b/modules/postprocess/gfpgan_model.py @@ -1,6 +1,6 @@ import os -import modules.face_restoration +from installer import install from modules import paths, shared, devices, modelloader, errors model_dir = "GFPGAN" @@ -72,8 +72,11 @@ def setup_model(dirname): except Exception: pass try: + install('basicsr') + install('gfpgan') import gfpgan import facexlib + import modules.face_restoration global user_path # pylint: disable=global-statement global have_gfpgan # pylint: disable=global-statement diff --git a/modules/textual_inversion/textual_inversion.py b/modules/textual_inversion/textual_inversion.py index fdf2342d4..d775cc722 100644 --- a/modules/textual_inversion/textual_inversion.py +++ b/modules/textual_inversion/textual_inversion.py @@ -9,6 +9,7 @@ from tqdm import tqdm import safetensors.torch import numpy as np from PIL import Image, PngImagePlugin +from installer import install from modules import shared, devices, processing, sd_models, images, errors import modules.textual_inversion.dataset from modules.textual_inversion.learn_schedule import LearnRateScheduler @@ -432,6 +433,7 @@ def write_loss(log_directory, filename, step, epoch_len, values): def tensorboard_setup(log_directory): + install('tensorboard') from torch.utils.tensorboard import SummaryWriter os.makedirs(os.path.join(log_directory, "tensorboard"), exist_ok=True) return SummaryWriter( diff --git a/requirements.txt b/requirements.txt index 1efe927cc..0415f98a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,12 @@ setuptools patch-ng -addict -aenum -aiohttp anyio -appdirs +addict astunparse blendmodes clean-fid -easydev -extcolors filetype future -gdown GitPython httpcore inflection @@ -30,7 +24,6 @@ resize-right rich safetensors scipy -tb_nightly tensordict==0.2.1 toml torchdiffeq @@ -40,7 +33,6 @@ scikit-image fasteners dctorch pymatting -matplotlib peft orjson httpx==0.24.1 From e0e4e41e6661442a3f6285d980618cd9fbcfd4bd Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 20:31:17 -0500 Subject: [PATCH 3/7] update wiki --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index ccc5298bf..768eb2558 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit ccc5298bf570be6804d63eafe8c20a9791cd91aa +Subproject commit 768eb25585aa15610bad358ba1adb66aa987f9f6 From 88de556445acb8708aabec06dc6fb14dc6b8bcef Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 22 Feb 2024 21:05:39 -0500 Subject: [PATCH 4/7] update todo and startup logging --- TODO.md | 9 +++++++-- installer.py | 2 +- modules/api/middleware.py | 2 +- webui.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index f27044535..6a48f27eb 100644 --- a/TODO.md +++ b/TODO.md @@ -5,13 +5,18 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Candidates for next release - stable cascade -- init latents, variations, tiling -- lora sliders: +- init latents: variations, tiling, img2img - x-adapter: - diffusers public callbacks - image2video: pia and vgen pipelines - video2video - async lowvram: +- remove builtin: controlnet +- remove builtin: image-browser +- defork +- remove training: ti +- remove training: hypernetwork +- extra network hide page with no entries ## Control missing features diff --git a/installer.py b/installer.py index cfb322cf5..0aae1b9b8 100644 --- a/installer.py +++ b/installer.py @@ -1039,7 +1039,7 @@ def extensions_preload(parser): preload_extensions(ext_dir, parser) t1 = time.time() preload_time[ext_dir] = round(t1 - t0, 2) - log.info(f'Extension preload: {preload_time}') + log.debug(f'Extension preload: {preload_time}') except Exception: log.error('Error running extension preloading') if args.profile: diff --git a/modules/api/middleware.py b/modules/api/middleware.py index 978d14b11..4c004ca08 100644 --- a/modules/api/middleware.py +++ b/modules/api/middleware.py @@ -18,7 +18,6 @@ errors.install() def setup_middleware(app: FastAPI, cmd_opts): - log.info('Initializing middleware') ssl._create_default_https_context = ssl._create_unverified_context # pylint: disable=protected-access uvicorn_logger=logging.getLogger("uvicorn.error") uvicorn_logger.disabled = True @@ -91,3 +90,4 @@ def setup_middleware(app: FastAPI, cmd_opts): return handle_exception(req, e) app.build_middleware_stack() # rebuild middleware stack on-the-fly + log.debug(f'FastAPI middleware: {[m.__class__.__name__ for m in app.user_middleware]}') diff --git a/webui.py b/webui.py index a92830858..e39c3ead6 100644 --- a/webui.py +++ b/webui.py @@ -105,7 +105,7 @@ def initialize(): t_timer, t_total = modules.scripts.load_scripts() timer.startup.record("extensions") timer.startup.records["extensions"] = t_total # scripts can reset the time - log.info(f'Extensions init time: {t_timer.summary()}') + log.debug(f'Extensions init time: {t_timer.summary()}') modelloader.load_upscalers() timer.startup.record("upscalers") From 1b976f610c881a3508abbdb3e01a9aba86a40c27 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 23 Feb 2024 00:29:19 -0500 Subject: [PATCH 5/7] update requirements --- modules/sd_models.py | 10 ++++++++-- requirements.txt | 2 +- wiki | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/sd_models.py b/modules/sd_models.py index 01a847439..798324442 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -864,8 +864,14 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No if debug_load: errors.display(e, 'Load') return - elif 'ONNX' in model_type: # forced pipeline - sd_model = pipeline.from_pretrained(checkpoint_info.path) + elif model_type is not None and pipeline is not None and 'ONNX' in model_type: # forced pipeline + try: + sd_model = pipeline.from_pretrained(checkpoint_info.path) + except Exception as e: + shared.log.error(f'ONNX Failed loading {op}: {checkpoint_info.path} {e}') + if debug_load: + errors.display(e, 'Load') + return else: err1, err2, err3 = None, None, None # diffusers_load_config['use_safetensors'] = True diff --git a/requirements.txt b/requirements.txt index 0415f98a8..4ffec69bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,7 @@ resize-right rich safetensors scipy -tensordict==0.2.1 +tensordict==0.1.2 toml torchdiffeq voluptuous diff --git a/wiki b/wiki index 768eb2558..9c62124db 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 768eb25585aa15610bad358ba1adb66aa987f9f6 +Subproject commit 9c62124dbe7521162a22b297481aadfae1deeb01 From 1bbcf2e13d672aae0ad79cdc088e00fc1a72b5ab Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 23 Feb 2024 08:54:32 -0500 Subject: [PATCH 6/7] minor fixes --- TODO.md | 2 ++ modules/face/__init__.py | 2 +- modules/shared.py | 2 ++ modules/theme.py | 6 +++++- modules/ui_javascript.py | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 6a48f27eb..8bf519283 100644 --- a/TODO.md +++ b/TODO.md @@ -17,6 +17,8 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma - remove training: ti - remove training: hypernetwork - extra network hide page with no entries +- ipadapter masking: +- theme/cozynest: ## Control missing features diff --git a/modules/face/__init__.py b/modules/face/__init__.py index f26d841eb..e0d76b689 100644 --- a/modules/face/__init__.py +++ b/modules/face/__init__.py @@ -72,7 +72,7 @@ class Script(scripts.Script): id_strength = gr.Slider(label='Strength', minimum=0.0, maximum=2.0, step=0.01, value=1.0) id_conditioning = gr.Slider(label='Control', minimum=0.0, maximum=2.0, step=0.01, value=0.5) with gr.Row(visible=True): - id_cache = gr.Checkbox(label='Cache model', value=True) + id_cache = gr.Checkbox(label='Cache model', value=False) with gr.Group(visible=False) as cfg_photomaker: with gr.Row(): gr.HTML('  Tenecent ARC Lab PhotoMaker
') diff --git a/modules/shared.py b/modules/shared.py index 937073bf1..526d27731 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -295,6 +295,8 @@ def temp_disable_extensions(): disable_themes.append('sdnext-ui-ux') if theme_name.lower() != 'lobe': disable_themes.append('sd-webui-lobe-theme') + if theme_name.lower() != 'cozy-nest': + disable_themes.append('Cozy-Nest') for ext in disable_themes: if ext not in opts.disabled_extensions: disabled.append(ext) diff --git a/modules/theme.py b/modules/theme.py index 7380b3672..eb594834e 100644 --- a/modules/theme.py +++ b/modules/theme.py @@ -49,7 +49,11 @@ def list_themes(): if f.endswith('.css'): engines.append(f'modern/{os.path.splitext(f)[0]}') if 'sd-webui-lobe-theme' in extensions: + modules.shared.log.info('Theme: installed="lobe"') engines.append('lobe') + if 'Cozy-Nest' in extensions: + modules.shared.log.info('Theme: installed="cozy-nest"') + engines.append('cozy-nest') gradio = ["gradio/default", "gradio/base", "gradio/glass", "gradio/monochrome", "gradio/soft"] huggingface = refresh_themes(no_update=True) huggingface = {x['id'] for x in huggingface if x['status'] == 'RUNNING' and 'test' not in x['id'].lower()} @@ -75,7 +79,7 @@ def reload_gradio_theme(theme_name=None): gradio_theme = gr.themes.Base(**default_font_params) modules.shared.log.info(f'UI theme: name="{theme_name}" style={modules.shared.opts.theme_style} base={base}') return True - elif theme_name.lower() in ['lobe']: + elif theme_name.lower() in ['lobe', 'cozy-nest']: gradio_theme = gr.themes.Base(**default_font_params) modules.shared.log.info(f'UI theme: name="{theme_name}" style={modules.shared.opts.theme_style} base={base}') elif theme_name.lower() == 'modern' or theme_name.lower().startswith('modern/'): diff --git a/modules/ui_javascript.py b/modules/ui_javascript.py index 7bcb0dc27..b6201c3cb 100644 --- a/modules/ui_javascript.py +++ b/modules/ui_javascript.py @@ -58,6 +58,8 @@ def html_css(is_builtin: bool): head += stylesheet(cssfile) theme_name = modules.shared.cmd_opts.theme or modules.shared.opts.gradio_theme or '' + if theme_name == 'default': + theme_name = 'black-teal' if theme_name.startswith('modern/'): theme_name = theme_name[7:] theme_folder = next((e.path for e in modules.extensions.extensions if e.name == 'sdnext-ui-ux'), None) From 92c3c267292e3c67f495c002cac8ed8c80ca01c3 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 23 Feb 2024 09:22:57 -0500 Subject: [PATCH 7/7] hide en with no entries --- TODO.md | 9 ++++----- ...ifferrential.jpg => screenshot-differential.jpg} | Bin modules/ui_extra_networks.py | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) rename html/{screenshot-differrential.jpg => screenshot-differential.jpg} (100%) diff --git a/TODO.md b/TODO.md index 8bf519283..a77609141 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,9 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Candidates for next release -- stable cascade +- defork +- stable cascade: +- ipadapter masking: - init latents: variations, tiling, img2img - x-adapter: - diffusers public callbacks @@ -13,15 +15,12 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma - async lowvram: - remove builtin: controlnet - remove builtin: image-browser -- defork - remove training: ti - remove training: hypernetwork -- extra network hide page with no entries -- ipadapter masking: -- theme/cozynest: ## Control missing features - second pass: - control api - masking api +- preprocess api diff --git a/html/screenshot-differrential.jpg b/html/screenshot-differential.jpg similarity index 100% rename from html/screenshot-differrential.jpg rename to html/screenshot-differential.jpg diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index eb78940a7..9dabf5565 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -585,6 +585,8 @@ def create_ui(container, button_parent, tabname, skip_indexing = False): executor.submit(page.create_items, ui.tabname) for page in get_pages(): page.create_page(ui.tabname, skip_indexing) + if len(page.items) == 0: + continue with gr.Tab(page.title, id=page.title.lower().replace(" ", "_"), elem_classes="extra-networks-tab") as tab: page_html = gr.HTML(page.html, elem_id=f'{tabname}{page.name}_extra_page', elem_classes="extra-networks-page") ui.pages.append(page_html)