mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-01-26 19:29:54 +00:00
fix: disable when inpaint with skip img2img
bug!
This commit is contained in:
@@ -201,7 +201,7 @@ class AfterDetailerScript(scripts.Script):
|
||||
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 @@ class AfterDetailerScript(scripts.Script):
|
||||
|
||||
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 @@ class AfterDetailerScript(scripts.Script):
|
||||
print(msg)
|
||||
return
|
||||
|
||||
if self.is_ad_enabled(*args_):
|
||||
arg_list = self.get_args(p, *args_)
|
||||
self.check_skip_img2img(p, *args_)
|
||||
|
||||
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)
|
||||
else:
|
||||
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
|
||||
|
||||
arg_list = self.get_args(p, *args_)
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user