Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 17, 2024
1 parent d5cea64 commit 9be6371
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
6 changes: 5 additions & 1 deletion aaaaaa/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,8 @@ def controlnet(w: Widgets, n: int, is_img2img: bool):
)

with gr.Column(variant="compact"):
w.ad_solo_generation = gr.Checkbox(label="Solo generation" + suffix(n), value=False, elem_id=eid("ad_solo_generation"))
w.ad_solo_generation = gr.Checkbox(
label="Solo generation" + suffix(n),
value=False,
elem_id=eid("ad_solo_generation"),
)
26 changes: 16 additions & 10 deletions scripts/!adetailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ def postprocess_image(self, p, pp: PPImage, *args_):
is_processed |= self._postprocess_image_inner(p, pp, args, n=n)

if n < last_index:
save_incrementals.append((n,copy(pp.image)))
save_incrementals.append((n, copy(pp.image)))

for n, args in enumerate(arg_list):
if args.need_skip() or args.ad_solo_generation is False:
Expand All @@ -931,7 +931,10 @@ def postprocess_image(self, p, pp: PPImage, *args_):
if is_processed:
if not is_skip_img2img(p):
self.save_image(
p, init_image, condition="ad_save_images_before", suffix="-ad-before"
p,
init_image,
condition="ad_save_images_before",
suffix="-ad-before",
)

for save in save_incrementals:
Expand All @@ -944,7 +947,9 @@ def postprocess_image(self, p, pp: PPImage, *args_):

all_extra_params = p.extra_generation_params
for save in save_solos:
p.extra_generation_params = self.fix_extra_generation_params(all_extra_params, save[2])
p.extra_generation_params = self.fix_extra_generation_params(
all_extra_params, save[2]
)
self.save_image(
p,
save[1],
Expand All @@ -961,24 +966,25 @@ def postprocess_image(self, p, pp: PPImage, *args_):

self.write_params_txt(params_txt_content)

def fix_extra_generation_params(self, params:dict, args:ADetailerArgs):
def fix_extra_generation_params(self, params: dict, args: ADetailerArgs):
ad_params = {}
for params_k in list(params.keys()):
found = False
for i, (k,v) in enumerate (_all_args):
for i, (k, v) in enumerate(_all_args):
if v in params_k:
found = True
break
if not found:
ad_params[params_k] = params[params_k]

for i, (k,v) in enumerate (_all_args):
if hasattr(args,k):
args_v = getattr(args,k)
if args_v is not None and args_v != '':
for i, (k, v) in enumerate(_all_args):
if hasattr(args, k):
args_v = getattr(args, k)
if args_v is not None and args_v != "":
ad_params[v] = args_v
return ad_params



def on_after_component(component, **_kwargs):
global txt2img_submit_button, img2img_submit_button
if getattr(component, "elem_id", None) == "txt2img_generate":
Expand Down

0 comments on commit 9be6371

Please sign in to comment.