diff --git a/TODO.md b/TODO.md index ed0b7c875..f67eeebfa 100644 --- a/TODO.md +++ b/TODO.md @@ -61,3 +61,5 @@ Tech that can be integrated as part of the core workflow... ### Pending Code Updates +- add optional models description shown in extra networks cards +- Add option to specify fallback sampler if primary sampler is not compatible with desired operation diff --git a/modules/cmd_args.py b/modules/cmd_args.py index 87b47d6c7..a1afcd2bd 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -74,6 +74,7 @@ def compatibility_args(opts, args): parser.add_argument("--sub-quad-q-chunk-size", help=argparse.SUPPRESS, default=opts.sub_quad_q_chunk_size) parser.add_argument("--sub-quad-kv-chunk-size", help=argparse.SUPPRESS, default=opts.sub_quad_kv_chunk_size) parser.add_argument("--sub-quad-chunk-threshold", help=argparse.SUPPRESS, default=opts.sub_quad_chunk_threshold) + parser.add_argument("--dimensions-and-batch-together", help=argparse.SUPPRESS, default=True) opts.use_old_emphasis_implementation = False opts.use_old_karras_scheduler_sigmas = False diff --git a/modules/processing.py b/modules/processing.py index 0ce6d4c91..1d49da237 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -973,7 +973,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing): img2img_sampler_name = self.sampler_name if self.sampler_name in ['PLMS', 'UniPC']: # PLMS/UniPC do not support img2img so we just silently switch to DDIM - img2img_sampler_name = 'DDIM' + img2img_sampler_name = shared.opts.fallback_sampler self.sampler = sd_samplers.create_sampler(img2img_sampler_name, self.sd_model) samples = samples[:, :, self.truncate_y//2:samples.shape[2]-(self.truncate_y+1)//2, self.truncate_x//2:samples.shape[3]-(self.truncate_x+1)//2] diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index 86007f906..11b76ca3d 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -13,7 +13,7 @@ import modules.errors as errors class UpscalerRealESRGAN(Upscaler): def __init__(self, path): self.name = "RealESRGAN" - self.user_path = path + self.model_path = path super().__init__() try: from basicsr.archs.rrdbnet_arch import RRDBNet @@ -31,7 +31,7 @@ class UpscalerRealESRGAN(Upscaler): self.enable = False self.scalers = [] - def do_upscale(self, img, path): + def do_upscale(self, img, selected_model): if not self.enable: return img @@ -41,9 +41,9 @@ class UpscalerRealESRGAN(Upscaler): print("Error importing Real-ESRGAN:", file=sys.stderr) return img - info = self.load_model(path) + info = self.load_model(selected_model) if not os.path.exists(info.local_data_path): - print("Unable to load RealESRGAN model: %s" % info.name) + print(f"Unable to load RealESRGAN model: {info.name}") return img upsampler = RealESRGANer( @@ -67,7 +67,6 @@ class UpscalerRealESRGAN(Upscaler): if info is None: print(f"Unable to find model info: {path}") return None - 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: @@ -127,6 +126,6 @@ def get_realesrgan_models(scaler): ), ] return models - except Exception as e: + except Exception: print("Error creating Real-ESRGAN models list", file=sys.stderr) return [] diff --git a/modules/shared.py b/modules/shared.py index d1f605053..466ec6605 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -431,6 +431,7 @@ options_templates.update(options_section(('ui', "Live previews"), { options_templates.update(options_section(('sampler-params', "Sampler parameters"), { "show_samplers": OptionInfo(["Euler a", "UniPC", "DDIM", "DPM++ SDE", "DPM++ SDE", "DPM2 Karras", "DPM++ 2M Karras"], "Show samplers in user interface", gr.CheckboxGroup, lambda: {"choices": [x.name for x in list_samplers()]}), + "fallback_sampler": OptionInfo("Euler a", "Fallback sampler if primary sampler is not compatible", gr.Dropdown, lambda: {"choices": [x.name for x in list_samplers()]}), "eta_ancestral": OptionInfo(1.0, "Noise multiplier for ancestral samplers (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), "eta_ddim": OptionInfo(0.0, "Noise multiplier for DDIM (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), "ddim_discretize": OptionInfo('uniform', "DDIM discretize img2img", gr.Radio, {"choices": ['uniform', 'quad']}), diff --git a/modules/upscaler.py b/modules/upscaler.py index 0376d256c..9ca6e4596 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -54,7 +54,7 @@ class Upscaler: dest_w = int(img.width * scale) dest_h = int(img.height * scale) - for i in range(3): + for _i in range(3): shape = (img.width, img.height) img = self.do_upscale(img, selected_model) @@ -74,7 +74,7 @@ class Upscaler: def load_model(self, path: str): pass - def find_models(self, ext_filter=None) -> list: + def find_models(self, ext_filter=None) -> list: # pylint: disable=unused-argument return modelloader.load_models(model_path=self.model_path, model_url=self.model_url, command_path=self.user_path) def update_status(self, prompt): @@ -107,7 +107,7 @@ class UpscalerNone(Upscaler): def do_upscale(self, img, selected_model=None): return img - def __init__(self, dirname=None): + def __init__(self, dirname=None): # pylint: disable=unused-argument super().__init__(False) self.scalers = [UpscalerData("None", None, self)] @@ -121,7 +121,7 @@ class UpscalerLanczos(Upscaler): def load_model(self, _): pass - def __init__(self, dirname=None): + def __init__(self, dirname=None): # pylint: disable=unused-argument super().__init__(False) self.name = "Lanczos" self.scalers = [UpscalerData("Lanczos", None, self)] @@ -136,7 +136,7 @@ class UpscalerNearest(Upscaler): def load_model(self, _): pass - def __init__(self, dirname=None): + def __init__(self, dirname=None): # pylint: disable=unused-argument super().__init__(False) self.name = "Nearest" self.scalers = [UpscalerData("Nearest", None, self)]