From a17f97643ee13cfe94e54bc96d4079fc01ec2e64 Mon Sep 17 00:00:00 2001 From: Dowon Date: Wed, 17 Jul 2024 20:13:22 +0900 Subject: [PATCH 01/13] fix(scripts): fix default scheduler --- scripts/!adetailer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index d4bbfc6..5b821be 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -382,7 +382,7 @@ def get_sampler(self, p, args: ADetailerArgs) -> str: def get_scheduler(self, p, args: ADetailerArgs) -> dict[str, str]: "webui >= 1.9.0" if not args.ad_use_sampler: - return {} + return {"scheduler": getattr(p, "scheduler", "Automatic")} if args.ad_scheduler == "Use same scheduler": value = getattr(p, "scheduler", "Automatic") From 0a9b7fdc3a606716b488f83abc8f1282bd62da94 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 20:17:09 +0900 Subject: [PATCH 02/13] [pre-commit.ci] pre-commit autoupdate (#648) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/rbubley/mirrors-prettier: v3.3.2 → v3.3.3](https://github.com/rbubley/mirrors-prettier/compare/v3.3.2...v3.3.3) - [github.com/astral-sh/ruff-pre-commit: v0.4.9 → v0.5.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.9...v0.5.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a9d22c..cec1ffc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,12 +17,12 @@ repos: - id: mixed-line-ending - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.3.2 + rev: v3.3.3 hooks: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.9 + rev: v0.5.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From ae98eb90ed6108a381d6a9b6601302c0b92c1151 Mon Sep 17 00:00:00 2001 From: Dowon Date: Wed, 17 Jul 2024 20:20:32 +0900 Subject: [PATCH 03/13] stype: fix ruff warnings --- aaaaaa/ui.py | 2 +- controlnet_ext/common.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aaaaaa/ui.py b/aaaaaa/ui.py index a678d82..2608ee3 100644 --- a/aaaaaa/ui.py +++ b/aaaaaa/ui.py @@ -82,7 +82,7 @@ def on_widget_change(state: dict, value: Any, *, attr: str): def on_generate_click(state: dict, *values: Any): for attr, value in zip(ALL_ARGS.attrs, values): - state[attr] = value + state[attr] = value # noqa: PERF403 state["is_api"] = () return state diff --git a/controlnet_ext/common.py b/controlnet_ext/common.py index b78dbf3..a9e0e97 100644 --- a/controlnet_ext/common.py +++ b/controlnet_ext/common.py @@ -8,4 +8,4 @@ "tile": "tile_resample", "depth": "depth_midas", } -cn_model_regex = re.compile("|".join(cn_model_module.keys()), flags=re.I) +cn_model_regex = re.compile("|".join(cn_model_module.keys()), flags=re.IGNORECASE) From ab845cf59617a40d5c260f627db82b16bb55410d Mon Sep 17 00:00:00 2001 From: Dowon Date: Wed, 17 Jul 2024 20:21:35 +0900 Subject: [PATCH 04/13] chore: dev version --- adetailer/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adetailer/__version__.py b/adetailer/__version__.py index a7f5098..e836370 100644 --- a/adetailer/__version__.py +++ b/adetailer/__version__.py @@ -1 +1 @@ -__version__ = "24.6.0" +__version__ = "24.7.0-dev.0" From db3be81c4ef48f16294f0131d2016676d7b3027c Mon Sep 17 00:00:00 2001 From: Dowon Date: Wed, 17 Jul 2024 20:27:56 +0900 Subject: [PATCH 05/13] feat: add controlnet union model --- aaaaaa/ui.py | 4 ++++ controlnet_ext/common.py | 3 ++- controlnet_ext/controlnet_ext.py | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/aaaaaa/ui.py b/aaaaaa/ui.py index 2608ee3..f7a5148 100644 --- a/aaaaaa/ui.py +++ b/aaaaaa/ui.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from functools import partial +from itertools import chain from types import SimpleNamespace from typing import Any @@ -42,6 +43,9 @@ "depth": ["depth_midas", "depth_hand_refiner"], } +union = list(chain.from_iterable(cn_module_choices.values())) +cn_module_choices["union"] = union + class Widgets(SimpleNamespace): def tolist(self): diff --git a/controlnet_ext/common.py b/controlnet_ext/common.py index a9e0e97..f485da5 100644 --- a/controlnet_ext/common.py +++ b/controlnet_ext/common.py @@ -8,4 +8,5 @@ "tile": "tile_resample", "depth": "depth_midas", } -cn_model_regex = re.compile("|".join(cn_model_module.keys()), flags=re.IGNORECASE) +_names = [*cn_model_module, "union"] +cn_model_regex = re.compile("|".join(_names), flags=re.IGNORECASE) diff --git a/controlnet_ext/controlnet_ext.py b/controlnet_ext/controlnet_ext.py index 9af1238..bcf7130 100644 --- a/controlnet_ext/controlnet_ext.py +++ b/controlnet_ext/controlnet_ext.py @@ -61,13 +61,13 @@ def update_scripts_args( if (not self.cn_available) or model == "None": return - if module is None or module == "None": + if module == "None": + module = None + if module is None: for m, v in cn_model_module.items(): if m in model: module = v break - else: - module = None cn_units = [ self.external_cn.ControlNetUnit( From 53998d67f11feadfbf2bb545cd0f29b36cc6f4c9 Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 20 Jul 2024 17:21:08 +0900 Subject: [PATCH 06/13] fix(scripts): revert exif prompt --- scripts/!adetailer.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 5b821be..2037b5e 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -616,23 +616,18 @@ def i2i_prompts_replace( i2i.negative_prompt = negative_prompt @staticmethod - def compare_prompt(p, extra_params: dict[str, Any], processed, n: int = 0): - if not hasattr(p, "_ad_extra_params_result"): - p._ad_extra_params_result = {} - + def compare_prompt(extra_params: dict[str, Any], processed, n: int = 0): pt = "ADetailer prompt" + suffix(n) if pt in extra_params and extra_params[pt] != processed.all_prompts[0]: print( f"[-] ADetailer: applied {ordinal(n + 1)} ad_prompt: {processed.all_prompts[0]!r}" ) - p._ad_extra_params_result[pt] = processed.all_prompts[0] ng = "ADetailer negative prompt" + suffix(n) if ng in extra_params and extra_params[ng] != processed.all_negative_prompts[0]: print( f"[-] ADetailer: applied {ordinal(n + 1)} ad_negative_prompt: {processed.all_negative_prompts[0]!r}" ) - p._ad_extra_params_result[ng] = processed.all_negative_prompts[0] @staticmethod def get_i2i_init_image(p, pp): @@ -784,7 +779,7 @@ def _postprocess_image_inner( finally: p2.close() - self.compare_prompt(p, p.extra_generation_params, processed, n=n) + self.compare_prompt(p.extra_generation_params, processed, n=n) p2 = copy(i2i) p2.init_images = [processed.images[0]] @@ -831,9 +826,6 @@ def postprocess_image(self, p, pp, *args_): self.write_params_txt(params_txt_content) - if hasattr(p, "_ad_extra_params_result"): - p.extra_generation_params.update(p._ad_extra_params_result) - def on_after_component(component, **_kwargs): global txt2img_submit_button, img2img_submit_button From 62591c43bd7acbf96b07daff292bee6f29682787 Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 20 Jul 2024 17:23:37 +0900 Subject: [PATCH 07/13] fix: fix typo --- aaaaaa/helper.py | 2 +- scripts/!adetailer.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aaaaaa/helper.py b/aaaaaa/helper.py index 27dd6a9..c9c50c9 100644 --- a/aaaaaa/helper.py +++ b/aaaaaa/helper.py @@ -45,7 +45,7 @@ def pause_total_tqdm(): @contextmanager -def preseve_prompts(p: PT): +def preserve_prompts(p: PT): all_pt = copy(p.all_prompts) all_ng = copy(p.all_negative_prompts) try: diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 2037b5e..e47df57 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -20,7 +20,7 @@ change_torch_load, copy_extra_params, pause_total_tqdm, - preseve_prompts, + preserve_prompts, ) from aaaaaa.p_method import ( get_i, @@ -447,8 +447,8 @@ def script_filter(self, p, args: ADetailerArgs): script_runner = copy(p.scripts) script_args = self.script_args_copy(p.script_args) - ad_only_seleted_scripts = opts.data.get("ad_only_seleted_scripts", True) - if not ad_only_seleted_scripts: + ad_only_selected_scripts = opts.data.get("ad_only_selected_scripts", True) + if not ad_only_selected_scripts: return script_runner, script_args ad_script_names_string: str = opts.data.get("ad_script_names", SCRIPT_DEFAULT) @@ -802,7 +802,7 @@ def postprocess_image(self, p, pp, *args_): if need_call_postprocess(p): dummy = Processed(p, [], p.seed, "") - with preseve_prompts(p): + with preserve_prompts(p): p.scripts.postprocess(copy(p), dummy) is_processed = False @@ -818,7 +818,7 @@ def postprocess_image(self, p, pp, *args_): ) if need_call_process(p): - with preseve_prompts(p): + with preserve_prompts(p): copy_p = copy(p) if hasattr(p.scripts, "before_process"): p.scripts.before_process(copy_p) @@ -854,7 +854,7 @@ def on_ui_settings(): "ad_extra_models_dir", shared.OptionInfo( default="", - label="Extra paths to scan adetailer models seperated by vertical bars(|)", + label="Extra paths to scan adetailer models separated by vertical bars(|)", component=gr.Textbox, section=section, ) @@ -873,7 +873,7 @@ def on_ui_settings(): ) shared.opts.add_option( - "ad_only_seleted_scripts", + "ad_only_selected_scripts", shared.OptionInfo( True, "Apply only selected scripts to ADetailer", section=section ), From 1985fa13e10a6e5d2f2b9a7fb4955810b50db16e Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 20 Jul 2024 17:27:38 +0900 Subject: [PATCH 08/13] fix(scripts): before process --- scripts/!adetailer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index e47df57..43865e5 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -820,8 +820,7 @@ def postprocess_image(self, p, pp, *args_): if need_call_process(p): with preserve_prompts(p): copy_p = copy(p) - if hasattr(p.scripts, "before_process"): - p.scripts.before_process(copy_p) + p.scripts.before_process(copy_p) p.scripts.process(copy_p) self.write_params_txt(params_txt_content) From b700b354d5704b9171b73883e772953ffe029a13 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 3 Aug 2024 13:06:59 +0900 Subject: [PATCH 09/13] [pre-commit.ci] pre-commit autoupdate (#666) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.2 → v0.5.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.2...v0.5.5) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cec1ffc..5e72304 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.2 + rev: v0.5.5 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From cdb7bd63578b875d039d94f41df67aea0f3359d5 Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 3 Aug 2024 12:57:09 +0900 Subject: [PATCH 10/13] fix: suppress mediapipe error --- adetailer/mediapipe.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adetailer/mediapipe.py b/adetailer/mediapipe.py index 25c6900..b05fa00 100644 --- a/adetailer/mediapipe.py +++ b/adetailer/mediapipe.py @@ -21,7 +21,10 @@ def mediapipe_predict( } if model_type in mapping: func = mapping[model_type] - return func(image, confidence) + try: + return func(image, confidence) + except Exception: + return PredictOutput() msg = f"[-] ADetailer: Invalid mediapipe model type: {model_type}, Available: {list(mapping.keys())!r}" raise RuntimeError(msg) From 23e3c5d7783827462420cdcbf64d7ef31d397d6e Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 3 Aug 2024 13:05:45 +0900 Subject: [PATCH 11/13] feat(script): same sampler option --- aaaaaa/ui.py | 9 +++++++-- scripts/!adetailer.py | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/aaaaaa/ui.py b/aaaaaa/ui.py index f7a5148..e4efb54 100644 --- a/aaaaaa/ui.py +++ b/aaaaaa/ui.py @@ -550,11 +550,16 @@ def inpainting(w: Widgets, n: int, is_img2img: bool, webui_info: WebuiInfo): elem_id=eid("ad_use_sampler"), ) + sampler_names = [ + "Use same sampler", + *webui_info.sampler_names, + ] + with gr.Row(): w.ad_sampler = gr.Dropdown( label="ADetailer sampler" + suffix(n), - choices=webui_info.sampler_names, - value=webui_info.sampler_names[0], + choices=sampler_names, + value=sampler_names[1], visible=True, elem_id=eid("ad_sampler"), ) diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 43865e5..b655e6e 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -374,7 +374,10 @@ def get_cfg_scale(self, p, args: ADetailerArgs) -> float: def get_sampler(self, p, args: ADetailerArgs) -> str: if args.ad_use_sampler: + if args.ad_sampler == "Use same sampler": + return p.sampler_name return args.ad_sampler + if hasattr(p, "_ad_orig"): return p._ad_orig.sampler_name return p.sampler_name From 7664737d82af87a5d07050c14f91ac118c3cc2db Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 3 Aug 2024 13:08:20 +0900 Subject: [PATCH 12/13] chore: update pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e72304..667ab5d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: prettier - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.5 + rev: v0.5.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 4f3daa76093649d27a502c816813221ca7025bec Mon Sep 17 00:00:00 2001 From: Dowon Date: Sat, 3 Aug 2024 13:20:07 +0900 Subject: [PATCH 13/13] chore: v24.8.0 --- CHANGELOG.md | 10 ++++++++++ adetailer/__version__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c542be7..2095da5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 2024-08-03 + +- v24.8.0 +- 샘플러 선택칸에 Use same sampler 옵션 추가 +- 컨트롤넷 유니온 모델을 선택할 수 있게 함 + +- webui 1.9.0이상에서 기본 스케줄러가 설정되지 않던 문제 수정 +- issus #656의 문제 해결을 위해 v24.4.0에 적용되었던 프롬프트 표시 기능을 되돌림 +- mediapipe에서 에러가 발생하면 추론이 실패한 것으로 처리하고 조용히 넘어감 + ## 2024-06-16 - v24.6.0 diff --git a/adetailer/__version__.py b/adetailer/__version__.py index e836370..45adada 100644 --- a/adetailer/__version__.py +++ b/adetailer/__version__.py @@ -1 +1 @@ -__version__ = "24.7.0-dev.0" +__version__ = "24.8.0"