diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-03 14:28:30 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-03 14:28:30 +0000 |
commit | 595c827bd31773cc98eb6e87b11090960a32b2a2 (patch) | |
tree | da1adfa7885262ae90cd79d8e0d5ecf6351d44a8 /modules/gfpgan_model.py | |
parent | f40617d6c4e366773677baa8d7f4114ba2893282 (diff) | |
download | stable-diffusion-webui-gfx803-595c827bd31773cc98eb6e87b11090960a32b2a2.tar.gz stable-diffusion-webui-gfx803-595c827bd31773cc98eb6e87b11090960a32b2a2.tar.bz2 stable-diffusion-webui-gfx803-595c827bd31773cc98eb6e87b11090960a32b2a2.zip |
option to unload GFPGAN after using
Diffstat (limited to 'modules/gfpgan_model.py')
-rw-r--r-- | modules/gfpgan_model.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/gfpgan_model.py b/modules/gfpgan_model.py index 3f42c163..334a1b7f 100644 --- a/modules/gfpgan_model.py +++ b/modules/gfpgan_model.py @@ -4,6 +4,7 @@ import traceback from modules.paths import script_path
from modules.shared import cmd_opts
+import modules.shared
def gfpgan_model_path():
@@ -23,10 +24,18 @@ loaded_gfpgan_model = None def gfpgan():
global loaded_gfpgan_model
- if loaded_gfpgan_model is None and gfpgan_constructor is not None:
- loaded_gfpgan_model = gfpgan_constructor(model_path=gfpgan_model_path(), upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None)
+ if loaded_gfpgan_model is not None:
+ return loaded_gfpgan_model
- return loaded_gfpgan_model
+ if gfpgan_constructor is None:
+ return None
+
+ model = gfpgan_constructor(model_path=gfpgan_model_path(), upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None)
+
+ if not cmd_opts.unload_gfpgan:
+ loaded_gfpgan_model = model
+
+ return model
def gfpgan_fix_faces(np_image):
|