aboutsummaryrefslogtreecommitdiffstats
path: root/extensions-builtin/LDSR/scripts/ldsr_model.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-04-29 14:22:24 +0000
committerGitHub <noreply@github.com>2023-04-29 14:22:24 +0000
commit78d0ee3bbaa2b48b7918e8088ad91c34f1ff2f1e (patch)
treeef6f32229611cab72bc1cfe088e2c60a70dbf41a /extensions-builtin/LDSR/scripts/ldsr_model.py
parent3ccf6f5ae8e57233200f9cac52da8d5d88ecee93 (diff)
parentc018eefe9173ae8f3669340479569dda78643a8a (diff)
downloadstable-diffusion-webui-gfx803-78d0ee3bbaa2b48b7918e8088ad91c34f1ff2f1e.tar.gz
stable-diffusion-webui-gfx803-78d0ee3bbaa2b48b7918e8088ad91c34f1ff2f1e.tar.bz2
stable-diffusion-webui-gfx803-78d0ee3bbaa2b48b7918e8088ad91c34f1ff2f1e.zip
Merge branch 'dev' into extension-settings-backup
Diffstat (limited to 'extensions-builtin/LDSR/scripts/ldsr_model.py')
-rw-r--r--extensions-builtin/LDSR/scripts/ldsr_model.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/extensions-builtin/LDSR/scripts/ldsr_model.py b/extensions-builtin/LDSR/scripts/ldsr_model.py
index b8cff29b..da19cff1 100644
--- a/extensions-builtin/LDSR/scripts/ldsr_model.py
+++ b/extensions-builtin/LDSR/scripts/ldsr_model.py
@@ -25,22 +25,28 @@ class UpscalerLDSR(Upscaler):
yaml_path = os.path.join(self.model_path, "project.yaml")
old_model_path = os.path.join(self.model_path, "model.pth")
new_model_path = os.path.join(self.model_path, "model.ckpt")
- safetensors_model_path = os.path.join(self.model_path, "model.safetensors")
+
+ local_model_paths = self.find_models(ext_filter=[".ckpt", ".safetensors"])
+ local_ckpt_path = next(iter([local_model for local_model in local_model_paths if local_model.endswith("model.ckpt")]), None)
+ local_safetensors_path = next(iter([local_model for local_model in local_model_paths if local_model.endswith("model.safetensors")]), None)
+ local_yaml_path = next(iter([local_model for local_model in local_model_paths if local_model.endswith("project.yaml")]), None)
+
if os.path.exists(yaml_path):
statinfo = os.stat(yaml_path)
if statinfo.st_size >= 10485760:
print("Removing invalid LDSR YAML file.")
os.remove(yaml_path)
+
if os.path.exists(old_model_path):
print("Renaming model from model.pth to model.ckpt")
os.rename(old_model_path, new_model_path)
- if os.path.exists(safetensors_model_path):
- model = safetensors_model_path
+
+ if local_safetensors_path is not None and os.path.exists(local_safetensors_path):
+ model = local_safetensors_path
else:
- model = load_file_from_url(url=self.model_url, model_dir=self.model_path,
- file_name="model.ckpt", progress=True)
- yaml = load_file_from_url(url=self.yaml_url, model_dir=self.model_path,
- file_name="project.yaml", progress=True)
+ model = local_ckpt_path if local_ckpt_path is not None else load_file_from_url(url=self.model_url, model_dir=self.model_path, file_name="model.ckpt", progress=True)
+
+ yaml = local_yaml_path if local_yaml_path is not None else load_file_from_url(url=self.yaml_url, model_dir=self.model_path, file_name="project.yaml", progress=True)
try:
return LDSR(model, yaml)