diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d889b0..8d30896 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,12 +8,12 @@ repos: - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.286" + rev: "v0.0.287" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.7.0 + rev: 23.9.0 hooks: - id: black diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b73cc80..f18738d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,5 +3,6 @@ "ms-python.black-formatter", "kevinrose.vsc-python-indent", "charliermarsh.ruff", + "shardulm94.trailing-spaces" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e84c60..89909b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2023-09-10 + +- v23.9.2 +- (실험적) VAE 선택 기능 + ## 2023-09-01 - v23.9.1 diff --git a/Taskfile.yml b/Taskfile.yml index 70786f2..70e0d35 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,3 +21,7 @@ tasks: lint: cmds: - pre-commit run -a + + update: + cmds: + - "{{.PYTHON}} -m pip install -U ultralytics mediapipe ruff pre-commit black" diff --git a/adetailer/__version__.py b/adetailer/__version__.py index bf51285..0a9df8e 100644 --- a/adetailer/__version__.py +++ b/adetailer/__version__.py @@ -1 +1 @@ -__version__ = "23.9.1" +__version__ = "23.9.2" diff --git a/adetailer/args.py b/adetailer/args.py index 42e60a4..ea22b99 100644 --- a/adetailer/args.py +++ b/adetailer/args.py @@ -61,6 +61,8 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid): ad_cfg_scale: NonNegativeFloat = 7.0 ad_use_checkpoint: bool = False ad_checkpoint: Optional[str] = None + ad_use_vae: bool = False + ad_vae: Optional[str] = None ad_use_sampler: bool = False ad_sampler: str = "DPM++ 2M Karras" ad_use_noise_multiplier: bool = False @@ -142,6 +144,10 @@ def extra_params(self, suffix: str = "") -> dict[str, Any]: "ADetailer use separate checkpoint", ["ADetailer use separate checkpoint", "ADetailer checkpoint"], ) + ppop( + "ADetailer use separate VAE", + ["ADetailer use separate VAE", "ADetailer VAE"], + ) ppop( "ADetailer use separate sampler", ["ADetailer use separate sampler", "ADetailer sampler"], @@ -216,6 +222,8 @@ def is_enabled(self) -> bool: ("ad_cfg_scale", "ADetailer CFG scale"), ("ad_use_checkpoint", "ADetailer use separate checkpoint"), ("ad_checkpoint", "ADetailer checkpoint"), + ("ad_use_vae", "ADetailer use separate VAE"), + ("ad_vae", "ADetailer VAE"), ("ad_use_sampler", "ADetailer use separate sampler"), ("ad_sampler", "ADetailer sampler"), ("ad_use_noise_multiplier", "ADetailer use separate noise multiplier"), diff --git a/adetailer/ui.py b/adetailer/ui.py index b186ed7..b05e3aa 100644 --- a/adetailer/ui.py +++ b/adetailer/ui.py @@ -29,7 +29,8 @@ class WebuiInfo: sampler_names: list[str] t2i_button: gr.Button i2i_button: gr.Button - checkpoints_list: Callable + checkpoints_list: list[str] + vae_list: list[str] def gr_interactive(value: bool = True): @@ -426,11 +427,7 @@ def inpainting(w: Widgets, n: int, is_img2img: bool, webui_info: WebuiInfo): elem_id=eid("ad_use_checkpoint"), ) - ckpts = ["Use same checkpoint"] - try: - ckpts.extend(webui_info.checkpoints_list(use_short=True)) - except TypeError: - ckpts.extend(webui_info.checkpoints_list()) + ckpts = ["Use same checkpoint", *webui_info.checkpoints_list] w.ad_checkpoint = gr.Dropdown( label="ADetailer checkpoint" + suffix(n), @@ -441,27 +438,45 @@ def inpainting(w: Widgets, n: int, is_img2img: bool, webui_info: WebuiInfo): ) with gr.Column(variant="compact"): - w.ad_use_sampler = gr.Checkbox( - label="Use separate sampler" + suffix(n), + w.ad_use_vae = gr.Checkbox( + label="Use separate VAE (experimental)" + suffix(n), value=False, visible=True, - elem_id=eid("ad_use_sampler"), + elem_id=eid("ad_use_vae"), ) - w.ad_sampler = gr.Dropdown( - label="ADetailer sampler" + suffix(n), - choices=webui_info.sampler_names, - value=webui_info.sampler_names[0], + vaes = ["Use same VAE", *webui_info.vae_list] + + w.ad_vae = gr.Dropdown( + label="ADetailer VAE" + suffix(n), + choices=vaes, + value=vaes[0], visible=True, - elem_id=eid("ad_sampler"), + elem_id=eid("ad_vae"), ) - w.ad_use_sampler.change( - gr_interactive, - inputs=w.ad_use_sampler, - outputs=w.ad_sampler, - queue=False, - ) + with gr.Row(), gr.Column(variant="compact"): + w.ad_use_sampler = gr.Checkbox( + label="Use separate sampler" + suffix(n), + value=False, + visible=True, + elem_id=eid("ad_use_sampler"), + ) + + w.ad_sampler = gr.Dropdown( + label="ADetailer sampler" + suffix(n), + choices=webui_info.sampler_names, + value=webui_info.sampler_names[0], + visible=True, + elem_id=eid("ad_sampler"), + ) + + w.ad_use_sampler.change( + gr_interactive, + inputs=w.ad_use_sampler, + outputs=w.ad_sampler, + queue=False, + ) with gr.Row(): with gr.Column(variant="compact"): diff --git a/install.py b/install.py index 9751baa..426d8fe 100644 --- a/install.py +++ b/install.py @@ -44,7 +44,7 @@ def run_pip(*args): def install(): deps = [ # requirements - ("ultralytics", "8.0.167", None), + ("ultralytics", "8.0.173", None), ("mediapipe", "0.10.3", None), ("rich", "13.0.0", None), # mediapipe diff --git a/scripts/!adetailer.py b/scripts/!adetailer.py index 5309c38..544e7b2 100644 --- a/scripts/!adetailer.py +++ b/scripts/!adetailer.py @@ -120,12 +120,20 @@ def ui(self, is_img2img): num_models = opts.data.get("ad_max_models", 2) ad_model_list = list(model_mapping.keys()) sampler_names = [sampler.name for sampler in all_samplers] + + try: + checkpoint_list = modules.sd_models.checkpoint_tiles(use_shorts=True) + except TypeError: + checkpoint_list = modules.sd_models.checkpoint_tiles() + vae_list = modules.shared_items.sd_vae_items() + webui_info = WebuiInfo( ad_model_list=ad_model_list, sampler_names=sampler_names, t2i_button=txt2img_submit_button, i2i_button=img2img_submit_button, - checkpoints_list=modules.sd_models.checkpoint_tiles, + checkpoints_list=checkpoint_list, + vae_list=vae_list, ) components, infotext_fields = adui(num_models, is_img2img, webui_info) @@ -318,6 +326,13 @@ def get_override_settings(self, p, args: ADetailerArgs) -> dict[str, Any]: and args.ad_checkpoint not in ("None", "Use same checkpoint") ): d["sd_model_checkpoint"] = args.ad_checkpoint + + if ( + args.ad_use_vae + and args.ad_vae + and args.ad_vae not in ("None", "Use same VAE") + ): + d["sd_vae"] = args.ad_vae return d def get_initial_noise_multiplier(self, p, args: ADetailerArgs) -> float | None: