diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 75a1e19..7c0bd31 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -201,7 +201,7 @@ def is_ad_enabled(self, *args_) -> bool: not_none = any(arg.get("ad_model", "None") != "None" for arg in arg_list) return ad_enabled and not_none - def check_skip_img2img(self, p, *args_) -> None: + def set_skip_img2img(self, p, *args_) -> None: if ( hasattr(p, "_ad_skip_img2img") or not hasattr(p, "init_images") @@ -211,20 +211,29 @@ def check_skip_img2img(self, p, *args_) -> None: if len(args_) >= 2 and isinstance(args_[1], bool): p._ad_skip_img2img = args_[1] - if args_[1]: - p._ad_orig = SkipImg2ImgOrig( - steps=p.steps, - sampler_name=p.sampler_name, - width=p.width, - height=p.height, - ) - p.steps = 1 - p.sampler_name = "Euler" - p.width = 128 - p.height = 128 else: p._ad_skip_img2img = False + if not p._ad_skip_img2img: + return + + if self.is_img2img_inpaint(p): + p._ad_disabled = True + msg = "[-] ADetailer: img2img inpainting with skip img2img is not supported. (because it's buggy)" + print(msg) + return + + p._ad_orig = SkipImg2ImgOrig( + steps=p.steps, + sampler_name=p.sampler_name, + width=p.width, + height=p.height, + ) + p.steps = 1 + p.sampler_name = "Euler" + p.width = 128 + p.height = 128 + @staticmethod def get_i(p) -> int: it = p.iteration @@ -672,21 +681,26 @@ def process(self, p, *args_): print(msg) return - if self.is_ad_enabled(*args_): - arg_list = self.get_args(p, *args_) - self.check_skip_img2img(p, *args_) + if not self.is_ad_enabled(*args_): + p._ad_disabled = True + return + + self.set_skip_img2img(p, *args_) + if getattr(p, "_ad_disabled", False): + # case when img2img inpainting with skip img2img + return - if hasattr(p, "_ad_xyz_prompt_sr"): - replaced_positive_prompt, replaced_negative_prompt = self.get_prompt( - p, arg_list[0] - ) - arg_list[0].ad_prompt = replaced_positive_prompt[0] - arg_list[0].ad_negative_prompt = replaced_negative_prompt[0] + arg_list = self.get_args(p, *args_) - extra_params = self.extra_params(arg_list) - p.extra_generation_params.update(extra_params) - else: - p._ad_disabled = True + if hasattr(p, "_ad_xyz_prompt_sr"): + replaced_positive_prompt, replaced_negative_prompt = self.get_prompt( + p, arg_list[0] + ) + arg_list[0].ad_prompt = replaced_positive_prompt[0] + arg_list[0].ad_negative_prompt = replaced_negative_prompt[0] + + extra_params = self.extra_params(arg_list) + p.extra_generation_params.update(extra_params) def _postprocess_image_inner( self, p, pp, args: ADetailerArgs, *, n: int = 0