diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-02 06:08:00 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-02 06:08:00 +0000 |
commit | b1717c0a4804f8ed3bb8cc2f3aea5d095778b447 (patch) | |
tree | c4a696c3fd656ae84bf12b3ad1076de59fb96134 /modules/shared.py | |
parent | 696c338ee2841830fd5010427d90347329d5786a (diff) | |
download | stable-diffusion-webui-gfx803-b1717c0a4804f8ed3bb8cc2f3aea5d095778b447.tar.gz stable-diffusion-webui-gfx803-b1717c0a4804f8ed3bb8cc2f3aea5d095778b447.tar.bz2 stable-diffusion-webui-gfx803-b1717c0a4804f8ed3bb8cc2f3aea5d095778b447.zip |
do not load wait for shared.sd_model to load at startup
Diffstat (limited to 'modules/shared.py')
-rw-r--r-- | modules/shared.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/modules/shared.py b/modules/shared.py index 6a2b3c2b..151bab9e 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -16,6 +16,7 @@ import modules.styles import modules.devices as devices
from modules import localization, script_loading, errors, ui_components, shared_items, cmd_args
from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir
+from ldm.models.diffusion.ddpm import LatentDiffusion
demo = None
@@ -600,13 +601,37 @@ class Options: return value
-
opts = Options()
if os.path.exists(config_filename):
opts.load(config_filename)
+
+class Shared(sys.modules[__name__].__class__):
+ """
+ this class is here to provide sd_model field as a property, so that it can be created and loaded on demand rather than
+ at program startup.
+ """
+
+ sd_model_val = None
+
+ @property
+ def sd_model(self):
+ import modules.sd_models
+
+ return modules.sd_models.model_data.get_sd_model()
+
+ @sd_model.setter
+ def sd_model(self, value):
+ import modules.sd_models
+
+ modules.sd_models.model_data.set_sd_model(value)
+
+
+sd_model: LatentDiffusion = None # this var is here just for IDE's type checking; it cannot be accessed because the class field above will be accessed instead
+sys.modules[__name__].__class__ = Shared
+
settings_components = None
-"""assinged from ui.py, a mapping on setting anmes to gradio components repsponsible for those settings"""
+"""assinged from ui.py, a mapping on setting names to gradio components repsponsible for those settings"""
latent_upscale_default_mode = "Latent"
latent_upscale_modes = {
@@ -620,8 +645,6 @@ latent_upscale_modes = { sd_upscalers = []
-sd_model = None
-
clip_model = None
progress_print_out = sys.stdout
|