From dc436b1f9de7dde84070e05be35faa97938e1ace Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 10 Nov 2023 08:28:33 -0500 Subject: [PATCH] fix --- modules/upscaler.py | 16 ++++++++++++++++ webui.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/upscaler.py b/modules/upscaler.py index e60f9a46c..6ad530a8b 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -51,6 +51,19 @@ class Upscaler: except Exception: pass + def find_folder(self, folder, scalers, loaded): + for fn in os.listdir(folder): # from folder + if not fn.endswith('.pth') and not fn.endswith('.pt'): + continue + file_name = os.path.join(folder, fn) + if file_name not in loaded: + model_name = os.path.splitext(fn)[0] + scaler = UpscalerData(name=f'{self.name} {model_name}', path=file_name, upscaler=self) + scaler.custom = True + scalers.append(scaler) + loaded.append(file_name) + modules.shared.log.debug(f'Upscaler type={self.name} folder="{folder}" model="{model_name}" path="{file_name}"') + def find_scalers(self): scalers = [] loaded = [] @@ -66,6 +79,8 @@ class Upscaler: # 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 + self.find_folder(self.user_path, scalers, loaded) + """ for fn in os.listdir(self.user_path): # from folder if not fn.endswith('.pth') and not fn.endswith('.pt'): continue @@ -77,6 +92,7 @@ class Upscaler: scalers.append(scaler) loaded.append(file_name) # modules.shared.log.debug(f'Upscaler type={self.name} folder="{self.user_path}" model="{model_name}" path="{file_name}"') + """ return scalers @abstractmethod diff --git a/webui.py b/webui.py index 91c0179d6..8397aced3 100644 --- a/webui.py +++ b/webui.py @@ -156,7 +156,7 @@ def initialize(): def load_model(): - if opts.sd_checkpoint_autoload and shared.cmd_opts.ckpt.lower() != 'none': + if opts.sd_checkpoint_autoload and (shared.cmd_opts.ckpt is not None and shared.cmd_opts.ckpt.lower() != 'none'): shared.state.begin('load') thread_model = Thread(target=lambda: shared.sd_model) thread_model.start()