From 653d253bfecbde9a7f0481928a114c6e1af0b0bf Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 10 Nov 2023 08:34:35 -0500 Subject: [PATCH] allow upscalers in subfolders --- modules/upscaler.py | 8 ++++++-- scripts/postprocessing_upscale.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/upscaler.py b/modules/upscaler.py index 6ad530a8b..52c50ff45 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -53,9 +53,12 @@ class Upscaler: 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 os.path.isdir(file_name): + self.find_folder(file_name, scalers, loaded) + continue + if not file_name.endswith('.pth') and not file_name.endswith('.pt'): + continue 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) @@ -63,6 +66,7 @@ class Upscaler: scalers.append(scaler) loaded.append(file_name) modules.shared.log.debug(f'Upscaler type={self.name} folder="{folder}" model="{model_name}" path="{file_name}"') + print(f'Upscaler type={self.name} folder="{folder}" model="{model_name}" path="{file_name}"') def find_scalers(self): scalers = [] diff --git a/scripts/postprocessing_upscale.py b/scripts/postprocessing_upscale.py index 0086a3abc..e97ac9b45 100644 --- a/scripts/postprocessing_upscale.py +++ b/scripts/postprocessing_upscale.py @@ -16,7 +16,7 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing): with FormRow(elem_id="extras_upscale"): with gr.Tabs(elem_id="extras_resize_mode"): with gr.TabItem('Scale by', elem_id="extras_scale_by_tab") as tab_scale_by: - upscaling_resize = gr.Slider(minimum=1.0, maximum=8.0, step=0.05, label="Resize", value=4, elem_id="extras_upscaling_resize") + upscaling_resize = gr.Slider(minimum=1.0, maximum=8.0, step=0.05, label="Resize", value=2.0, elem_id="extras_upscaling_resize") with gr.TabItem('Scale to', elem_id="extras_scale_to_tab") as tab_scale_to: with FormRow():