diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-01-17 10:57:55 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-01-17 10:57:55 +0000 |
commit | aede265f1d6d512ca9e51a305e98a96a215366c4 (patch) | |
tree | 60bb387d26d4ed011c91f7f43b44d8fd3490e6a5 | |
parent | c361b89026442f3412162657f330d500b803e052 (diff) | |
download | stable-diffusion-webui-gfx803-aede265f1d6d512ca9e51a305e98a96a215366c4.tar.gz stable-diffusion-webui-gfx803-aede265f1d6d512ca9e51a305e98a96a215366c4.tar.bz2 stable-diffusion-webui-gfx803-aede265f1d6d512ca9e51a305e98a96a215366c4.zip |
Fix unable to find Real-ESRGAN model info error (AttributeError: 'NoneType' object has no attribute 'data_path') #6841 #5170
-rw-r--r-- | modules/realesrgan_model.py | 12 | ||||
-rw-r--r-- | modules/upscaler.py | 1 |
2 files changed, 5 insertions, 8 deletions
diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index 3ac0b97a..47f70251 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -38,13 +38,13 @@ class UpscalerRealESRGAN(Upscaler): return img
info = self.load_model(path)
- if not os.path.exists(info.data_path):
+ if not os.path.exists(info.local_data_path):
print("Unable to load RealESRGAN model: %s" % info.name)
return img
upsampler = RealESRGANer(
scale=info.scale,
- model_path=info.data_path,
+ model_path=info.local_data_path,
model=info.model(),
half=not cmd_opts.no_half,
tile=opts.ESRGAN_tile,
@@ -58,17 +58,13 @@ class UpscalerRealESRGAN(Upscaler): def load_model(self, path):
try:
- info = None
- for scaler in self.scalers:
- if scaler.data_path == path:
- info = scaler
+ info = next(iter([scaler for scaler in self.scalers if scaler.data_path == path]), None)
if info is None:
print(f"Unable to find model info: {path}")
return None
- model_file = load_file_from_url(url=info.data_path, model_dir=self.model_path, progress=True)
- info.data_path = model_file
+ info.local_data_path = load_file_from_url(url=info.data_path, model_dir=self.model_path, progress=True)
return info
except Exception as e:
print(f"Error making Real-ESRGAN models list: {e}", file=sys.stderr)
diff --git a/modules/upscaler.py b/modules/upscaler.py index 231680cb..a5bf5acb 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -95,6 +95,7 @@ class UpscalerData: def __init__(self, name: str, path: str, upscaler: Upscaler = None, scale: int = 4, model=None): self.name = name self.data_path = path + self.local_data_path = path self.scaler = upscaler self.scale = scale self.model = model |