Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Bing-su committed Sep 10, 2023
2 parents 451b098 + 9e52dea commit a0b4c56
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"ms-python.black-formatter",
"kevinrose.vsc-python-indent",
"charliermarsh.ruff",
"shardulm94.trailing-spaces"
]
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2023-09-10

- v23.9.2
- (실험적) VAE 선택 기능

## 2023-09-01

- v23.9.1
Expand Down
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ tasks:
lint:
cmds:
- pre-commit run -a

update:
cmds:
- "{{.PYTHON}} -m pip install -U ultralytics mediapipe ruff pre-commit black"
2 changes: 1 addition & 1 deletion adetailer/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "23.9.1"
__version__ = "23.9.2"
8 changes: 8 additions & 0 deletions adetailer/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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"),
Expand Down
55 changes: 35 additions & 20 deletions adetailer/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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),
Expand All @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion scripts/!adetailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a0b4c56

Please sign in to comment.