diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-10 20:41:08 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-10 20:41:08 +0000 |
commit | 8aa87c564a79965013715d56a5f90d2a34d5d6ee (patch) | |
tree | 0a53fc8e1ffe7d24463b77c8ab2386797c6c4a8a /modules/modelloader.py | |
parent | 5abecea34cd98537f006c5e9a197acd1fe9db023 (diff) | |
download | stable-diffusion-webui-gfx803-8aa87c564a79965013715d56a5f90d2a34d5d6ee.tar.gz stable-diffusion-webui-gfx803-8aa87c564a79965013715d56a5f90d2a34d5d6ee.tar.bz2 stable-diffusion-webui-gfx803-8aa87c564a79965013715d56a5f90d2a34d5d6ee.zip |
add UI to edit defaults
allow setting defaults for elements in extensions' tabs
fix a problem with ESRGAN upscalers disappearing after UI reload
implicit change: HTML element id for train tab from tab_ti to tab_train (will this break things?)
Diffstat (limited to 'modules/modelloader.py')
-rw-r--r-- | modules/modelloader.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/modules/modelloader.py b/modules/modelloader.py index 25612bf8..2a479bcb 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -116,20 +116,6 @@ def move_files(src_path: str, dest_path: str, ext_filter: str = None): pass -builtin_upscaler_classes = [] -forbidden_upscaler_classes = set() - - -def list_builtin_upscalers(): - builtin_upscaler_classes.clear() - builtin_upscaler_classes.extend(Upscaler.__subclasses__()) - -def forbid_loaded_nonbuiltin_upscalers(): - for cls in Upscaler.__subclasses__(): - if cls not in builtin_upscaler_classes: - forbidden_upscaler_classes.add(cls) - - def load_upscalers(): # 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__ @@ -145,10 +131,17 @@ def load_upscalers(): datas = [] commandline_options = vars(shared.cmd_opts) - for cls in Upscaler.__subclasses__(): - if cls in forbidden_upscaler_classes: - continue + # some of upscaler classes will not go away after reloading their modules, and we'll end + # up with two copies of those classes. The newest copy will always be the last in the list, + # so we go from end to beginning and ignore duplicates + used_classes = {} + for cls in reversed(Upscaler.__subclasses__()): + classname = str(cls) + if classname not in used_classes: + used_classes[classname] = cls + + for cls in reversed(used_classes.values()): name = cls.__name__ cmd_name = f"{name.lower().replace('upscaler', '')}_models_path" scaler = cls(commandline_options.get(cmd_name, None)) |