From 079f5c9f2ad4f65dc0811e49fba7c0d7a9627dc3 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 18 Oct 2023 13:01:26 -0400 Subject: [PATCH] add compatibility reexport for codeformers --- CHANGELOG.md | 2 ++ modules/api/api.py | 3 ++- modules/postprocess/codeformer_model.py | 5 +---- modules/upscaler.py | 2 ++ webui.py | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d998f15..e09c0e9ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Service release addressing all zero-day issues reported so far... - fix freeu for backend original and add it to xyz grid - fix loading diffuser models in huggingface format from non-standard location - fix default styles looking in wrong location +- fix missing upscaler folder on initial startup +- enhance extension compatibility for exensions directly importing codeformers - update `typing-extensions` **Themes** diff --git a/modules/api/api.py b/modules/api/api.py index 163e11881..6cdb362d5 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -182,7 +182,8 @@ class Api: if shared.opts.motd: res = requests.get('https://vladmandic.github.io/automatic/motd', timeout=10) if res.status_code == 200: - shared.log.info(f'MOTD: {res.text}') + msg = (res.text or '').strip() + shared.log.info(f'MOTD: {msg if len(msg) > 0 else "N/A"}') motd += res.text return motd diff --git a/modules/postprocess/codeformer_model.py b/modules/postprocess/codeformer_model.py index e11747018..3f959b6b8 100644 --- a/modules/postprocess/codeformer_model.py +++ b/modules/postprocess/codeformer_model.py @@ -1,9 +1,6 @@ import os -import sys - import cv2 import torch - import modules.face_restoration from modules import shared, devices, modelloader, errors from modules.paths import models_path @@ -88,7 +85,7 @@ def setup_model(dirname): cropped_face_t = cropped_face_t.unsqueeze(0).to(devices.device_codeformer) try: with devices.inference_context(): - output = self.net(cropped_face_t, w=w if w is not None else shared.opts.code_former_weight, adain=True)[0] + output = self.net(cropped_face_t, w=w if w is not None else shared.opts.code_former_weight, adain=True)[0] # pylint: disable=not-callable restored_face = tensor2img(output, rgb2bgr=True, min_max=(-1, 1)) del output devices.torch_gc() diff --git a/modules/upscaler.py b/modules/upscaler.py index 45cdef63a..b05862f78 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -64,6 +64,8 @@ class Upscaler: scalers.append(scaler) loaded.append(model_path) # modules.shared.log.debug(f'Upscaler type={self.name} folder="{self.user_path}" model="{model[0]}" path="{model_path}"') + if not os.path.exists(self.user_path): + return scalers for fn in os.listdir(self.user_path): # from folder if not fn.endswith('.pth') and not fn.endswith('.pt'): continue diff --git a/webui.py b/webui.py index 1974cd89e..f8e750888 100644 --- a/webui.py +++ b/webui.py @@ -100,6 +100,7 @@ def initialize(): import modules.postprocess.codeformer_model as codeformer codeformer.setup_model(opts.codeformer_models_path) + sys.modules["modules.codeformer_model"] = codeformer import modules.postprocess.gfpgan_model as gfpgan gfpgan.setup_model(opts.gfpgan_models_path) timer.startup.record("face-restore")