This commit is contained in:
Vladimir Mandic
2023-11-10 08:28:33 -05:00
parent f775324ea2
commit dc436b1f9d
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -51,6 +51,19 @@ class Upscaler:
except Exception:
pass
def find_folder(self, folder, scalers, loaded):
for fn in os.listdir(folder): # from folder
if not fn.endswith('.pth') and not fn.endswith('.pt'):
continue
file_name = os.path.join(folder, fn)
if file_name not in loaded:
model_name = os.path.splitext(fn)[0]
scaler = UpscalerData(name=f'{self.name} {model_name}', path=file_name, upscaler=self)
scaler.custom = True
scalers.append(scaler)
loaded.append(file_name)
modules.shared.log.debug(f'Upscaler type={self.name} folder="{folder}" model="{model_name}" path="{file_name}"')
def find_scalers(self):
scalers = []
loaded = []
@@ -66,6 +79,8 @@ class Upscaler:
# modules.shared.log.debug(f'Upscaler type={self.name} folder="{self.user_path}" model="{model[0]}" path="{model_path}"')
if not os.path.exists(self.user_path):
return scalers
self.find_folder(self.user_path, scalers, loaded)
"""
for fn in os.listdir(self.user_path): # from folder
if not fn.endswith('.pth') and not fn.endswith('.pt'):
continue
@@ -77,6 +92,7 @@ class Upscaler:
scalers.append(scaler)
loaded.append(file_name)
# modules.shared.log.debug(f'Upscaler type={self.name} folder="{self.user_path}" model="{model_name}" path="{file_name}"')
"""
return scalers
@abstractmethod
+1 -1
View File
@@ -156,7 +156,7 @@ def initialize():
def load_model():
if opts.sd_checkpoint_autoload and shared.cmd_opts.ckpt.lower() != 'none':
if opts.sd_checkpoint_autoload and (shared.cmd_opts.ckpt is not None and shared.cmd_opts.ckpt.lower() != 'none'):
shared.state.begin('load')
thread_model = Thread(target=lambda: shared.sd_model)
thread_model.start()