fix for broken sampler selection in img2img and xy plot #4860 #4909

This commit is contained in:
AUTOMATIC 2022-11-27 13:17:39 +03:00
parent 5b2c316890
commit 40ca34b837
3 changed files with 9 additions and 9 deletions

View File

@ -99,7 +99,7 @@ def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, pro
seed_resize_from_h=seed_resize_from_h,
seed_resize_from_w=seed_resize_from_w,
seed_enable_extras=seed_enable_extras,
sampler_index=sd_samplers.samplers_for_img2img[sampler_index].name,
sampler_name=sd_samplers.samplers_for_img2img[sampler_index].name,
batch_size=batch_size,
n_iter=n_iter,
steps=steps,

View File

@ -74,7 +74,7 @@ class StableDiffusionProcessing():
"""
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt: str = "", styles: List[str] = None, seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1, seed_enable_extras: bool = True, sampler_name: str = None, batch_size: int = 1, n_iter: int = 1, steps: int = 50, cfg_scale: float = 7.0, width: int = 512, height: int = 512, restore_faces: bool = False, tiling: bool = False, do_not_save_samples: bool = False, do_not_save_grid: bool = False, extra_generation_params: Dict[Any, Any] = None, overlay_images: Any = None, negative_prompt: str = None, eta: float = None, do_not_reload_embeddings: bool = False, denoising_strength: float = 0, ddim_discretize: str = None, s_churn: float = 0.0, s_tmax: float = None, s_tmin: float = 0.0, s_noise: float = 1.0, override_settings: Dict[str, Any] = None, sampler_index: int = None):
if sampler_index is not None:
warnings.warn("sampler_index argument for StableDiffusionProcessing does not do anything; use sampler_name")
print("sampler_index argument for StableDiffusionProcessing does not do anything; use sampler_name", file=sys.stderr)
self.sd_model = sd_model
self.outpath_samples: str = outpath_samples

View File

@ -62,25 +62,25 @@ def apply_order(p, x, xs):
def build_samplers_dict():
samplers_dict = {}
for i, sampler in enumerate(sd_samplers.all_samplers):
samplers_dict[sampler.name.lower()] = i
for sampler in sd_samplers.all_samplers:
samplers_dict[sampler.name.lower()] = sampler.name
for alias in sampler.aliases:
samplers_dict[alias.lower()] = i
samplers_dict[alias.lower()] = sampler.name
return samplers_dict
def apply_sampler(p, x, xs):
sampler_index = build_samplers_dict().get(x.lower(), None)
if sampler_index is None:
sampler_name = build_samplers_dict().get(x.lower(), None)
if sampler_name is None:
raise RuntimeError(f"Unknown sampler: {x}")
p.sampler_index = sampler_index
p.sampler_name = sampler_name
def confirm_samplers(p, xs):
samplers_dict = build_samplers_dict()
for x in xs:
if x.lower() not in samplers_dict.keys():
if x.lower() not in samplers_dict:
raise RuntimeError(f"Unknown sampler: {x}")