diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-13 17:25:03 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-13 17:25:03 +0000 |
commit | 2053745c8fc29a0d3c1bbfa07858fb0b21b32e6d (patch) | |
tree | 8a80f841fc4a5d588e1214111990aca7472a8cc1 /modules/modelloader.py | |
parent | 231562ea13e4f697953bdbabd6b76b22a88c587b (diff) | |
parent | 27f7fbf35cd72d547d830f97828ee13d3d2009aa (diff) | |
download | stable-diffusion-webui-gfx803-2053745c8fc29a0d3c1bbfa07858fb0b21b32e6d.tar.gz stable-diffusion-webui-gfx803-2053745c8fc29a0d3c1bbfa07858fb0b21b32e6d.tar.bz2 stable-diffusion-webui-gfx803-2053745c8fc29a0d3c1bbfa07858fb0b21b32e6d.zip |
Merge branch 'v1.2.0-hotfix' into release_candidate
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 cb85ac4f..a70aa0e3 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -117,20 +117,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__ @@ -146,10 +132,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)) |