diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-02 14:39:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-02 14:39:34 +0000 |
commit | 6e063124acc06c13e8bfae37b1f1cd372f3e04ab (patch) | |
tree | e415d742fb86a9024eaeb8e38a18ebaa677e54ae /modules/modelloader.py | |
parent | f34e2293d0abffc412150f54ebb5c626101f6359 (diff) | |
parent | 5d26ba2b4b84b64d82150ae70495f928b3b0b116 (diff) | |
download | stable-diffusion-webui-gfx803-6e063124acc06c13e8bfae37b1f1cd372f3e04ab.tar.gz stable-diffusion-webui-gfx803-6e063124acc06c13e8bfae37b1f1cd372f3e04ab.tar.bz2 stable-diffusion-webui-gfx803-6e063124acc06c13e8bfae37b1f1cd372f3e04ab.zip |
Merge pull request #1403 from d8ahazard/ScuNET
Add ScuNET Denoiser/Upscaler, Fix some Model Loader issues
Diffstat (limited to 'modules/modelloader.py')
-rw-r--r-- | modules/modelloader.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/modules/modelloader.py b/modules/modelloader.py index 015aeafa..b0f2f33d 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -5,7 +5,6 @@ import importlib from urllib.parse import urlparse from basicsr.utils.download_util import load_file_from_url - from modules import shared from modules.upscaler import Upscaler from modules.paths import script_path, models_path @@ -121,16 +120,30 @@ def move_files(src_path: str, dest_path: str, ext_filter: str = None): def load_upscalers(): + sd = shared.script_path + # We can only do this 'magic' method to dynamically load upscalers if they are referenced, + # so we'll try to import any _model.py files before looking in __subclasses__ + modules_dir = os.path.join(sd, "modules") + for file in os.listdir(modules_dir): + if "_model.py" in file: + model_name = file.replace("_model.py", "") + full_model = f"modules.{model_name}_model" + try: + importlib.import_module(full_model) + except: + pass datas = [] + c_o = vars(shared.cmd_opts) for cls in Upscaler.__subclasses__(): name = cls.__name__ module_name = cls.__module__ module = importlib.import_module(module_name) class_ = getattr(module, name) - cmd_name = f"{name.lower().replace('upscaler', '')}-models-path" + cmd_name = f"{name.lower().replace('upscaler', '')}_models_path" opt_string = None try: - opt_string = shared.opts.__getattr__(cmd_name) + if cmd_name in c_o: + opt_string = c_o[cmd_name] except: pass scaler = class_(opt_string) |