diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-12-03 15:06:33 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-12-03 15:06:33 +0000 |
commit | b6e5edd74657e3fd1fbd04f341b7a84625d4aa7a (patch) | |
tree | bac9ddea7cafb768e064b75281edcfeac3a52ca1 /modules/modelloader.py | |
parent | 46b0d230e7c13e247eabb22e1103ce512e7ed6b1 (diff) | |
download | stable-diffusion-webui-gfx803-b6e5edd74657e3fd1fbd04f341b7a84625d4aa7a.tar.gz stable-diffusion-webui-gfx803-b6e5edd74657e3fd1fbd04f341b7a84625d4aa7a.tar.bz2 stable-diffusion-webui-gfx803-b6e5edd74657e3fd1fbd04f341b7a84625d4aa7a.zip |
add built-in extension system
add support for adding upscalers in extensions
move LDSR, ScuNET and SwinIR to built-in extensions
Diffstat (limited to 'modules/modelloader.py')
-rw-r--r-- | modules/modelloader.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/modules/modelloader.py b/modules/modelloader.py index 7d2f0ade..e647f6fa 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -124,10 +124,9 @@ 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") + modules_dir = os.path.join(shared.script_path, "modules") for file in os.listdir(modules_dir): if "_model.py" in file: model_name = file.replace("_model.py", "") @@ -136,22 +135,13 @@ def load_upscalers(): importlib.import_module(full_model) except: pass + datas = [] - c_o = vars(shared.cmd_opts) + commandline_options = 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" - opt_string = None - try: - if cmd_name in c_o: - opt_string = c_o[cmd_name] - except: - pass - scaler = class_(opt_string) - for child in scaler.scalers: - datas.append(child) + scaler = cls(commandline_options.get(cmd_name, None)) + datas += scaler.scalers shared.sd_upscalers = datas |