aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ldsr_model.py
diff options
context:
space:
mode:
authord8ahazard <d8ahazard@gmail.com>2022-09-30 13:41:25 +0000
committerd8ahazard <d8ahazard@gmail.com>2022-09-30 13:41:25 +0000
commit64c6b13312ff3a20f48781c4c3780355c4b7b2af (patch)
treee34b3eb213c39356e02cfe6b4d4cf725cd36c2cd /modules/ldsr_model.py
parent41f9449d96488017092d229d65f674c2e8252697 (diff)
downloadstable-diffusion-webui-gfx803-64c6b13312ff3a20f48781c4c3780355c4b7b2af.tar.gz
stable-diffusion-webui-gfx803-64c6b13312ff3a20f48781c4c3780355c4b7b2af.tar.bz2
stable-diffusion-webui-gfx803-64c6b13312ff3a20f48781c4c3780355c4b7b2af.zip
Remove LDSR project.yaml if too large.
If we accidentally downloaded the wrong file and saved it as project.yaml, this will delete it so it can be re-downloaded.
Diffstat (limited to 'modules/ldsr_model.py')
-rw-r--r--modules/ldsr_model.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/ldsr_model.py b/modules/ldsr_model.py
index 877e7e73..4d8687c2 100644
--- a/modules/ldsr_model.py
+++ b/modules/ldsr_model.py
@@ -22,6 +22,13 @@ class UpscalerLDSR(Upscaler):
self.scalers = [scaler_data]
def load_model(self, path: str):
+ # Remove incorrect project.yaml file if too big
+ yaml_path = os.path.join(self.model_path, "project.yaml")
+ 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)
model = load_file_from_url(url=self.model_url, model_dir=self.model_path,
file_name="model.pth", progress=True)
yaml = load_file_from_url(url=self.yaml_url, model_dir=self.model_path,