aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ldsr_model.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-01-04 15:57:14 +0000
committerGitHub <noreply@github.com>2023-01-04 15:57:14 +0000
commit32547f2721c92794779e6ff9fb325243d5857cae (patch)
treed4d5f1a9705e59eef5029cc1be3bff57fbd389c2 /modules/ldsr_model.py
parentfe6e2362e8fa5d739de6997ab155a26686d20a49 (diff)
parent3dae545a03f5102ba5d9c3f27bb6241824c5a916 (diff)
downloadstable-diffusion-webui-gfx803-32547f2721c92794779e6ff9fb325243d5857cae.tar.gz
stable-diffusion-webui-gfx803-32547f2721c92794779e6ff9fb325243d5857cae.tar.bz2
stable-diffusion-webui-gfx803-32547f2721c92794779e6ff9fb325243d5857cae.zip
Merge branch 'master' into xygrid_infotext_improvements
Diffstat (limited to 'modules/ldsr_model.py')
-rw-r--r--modules/ldsr_model.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/modules/ldsr_model.py b/modules/ldsr_model.py
deleted file mode 100644
index 1c1070fc..00000000
--- a/modules/ldsr_model.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import os
-import sys
-import traceback
-
-from basicsr.utils.download_util import load_file_from_url
-
-from modules.upscaler import Upscaler, UpscalerData
-from modules.ldsr_model_arch import LDSR
-from modules import shared
-from modules.paths import models_path
-
-
-class UpscalerLDSR(Upscaler):
- def __init__(self, user_path):
- self.name = "LDSR"
- self.model_path = os.path.join(models_path, self.name)
- self.user_path = user_path
- self.model_url = "https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1"
- self.yaml_url = "https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1"
- super().__init__()
- scaler_data = UpscalerData("LDSR", None, self)
- 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")
- old_model_path = os.path.join(self.model_path, "model.pth")
- new_model_path = os.path.join(self.model_path, "model.ckpt")
- 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)
- 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)
-
- try:
- return LDSR(model, yaml)
-
- except Exception:
- print("Error importing LDSR:", file=sys.stderr)
- print(traceback.format_exc(), file=sys.stderr)
- return None
-
- def do_upscale(self, img, path):
- ldsr = self.load_model(path)
- if ldsr is None:
- print("NO LDSR!")
- return img
- ddim_steps = shared.opts.ldsr_steps
- return ldsr.super_resolution(img, ddim_steps, self.scale)