mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-01-26 11:19:53 +00:00
feat: update controlnet preprocessors
This commit is contained in:
@@ -11,11 +11,21 @@ from adetailer import AFTER_DETAILER, __version__
|
||||
from adetailer.args import ALL_ARGS, MASK_MERGE_INVERT
|
||||
from controlnet_ext import controlnet_exists, get_cn_models
|
||||
|
||||
cn_module_choices = [
|
||||
"inpaint_global_harmonious",
|
||||
"inpaint_only",
|
||||
"inpaint_only+lama",
|
||||
]
|
||||
cn_module_choices = {
|
||||
"inpaint": [
|
||||
"inpaint_global_harmonious",
|
||||
"inpaint_only",
|
||||
"inpaint_only+lama",
|
||||
],
|
||||
"lineart": [
|
||||
"lineart_coarse",
|
||||
"lineart_realistic",
|
||||
"lineart_anime",
|
||||
"lineart_anime_denoise",
|
||||
],
|
||||
"openpose": ["openpose_full", "dw_openpose_full"],
|
||||
"tile": ["tile_resample", "tile_colorfix", "tile_colorfix+sharp"],
|
||||
}
|
||||
|
||||
|
||||
class Widgets(SimpleNamespace):
|
||||
@@ -58,11 +68,11 @@ def on_generate_click(state: dict, *values: Any):
|
||||
return state
|
||||
|
||||
|
||||
def on_cn_model_update(cn_model: str):
|
||||
if "inpaint" in cn_model:
|
||||
return gr.update(
|
||||
visible=True, choices=cn_module_choices, value=cn_module_choices[0]
|
||||
)
|
||||
def on_cn_model_update(cn_model_name: str):
|
||||
for t in cn_module_choices:
|
||||
if t in cn_model_name:
|
||||
choices = cn_module_choices[t]
|
||||
return gr.update(visible=True, choices=choices, value=choices[0])
|
||||
return gr.update(visible=False, choices=["None"], value="None")
|
||||
|
||||
|
||||
@@ -564,8 +574,8 @@ def controlnet(w: Widgets, n: int, is_img2img: bool):
|
||||
|
||||
w.ad_controlnet_module = gr.Dropdown(
|
||||
label="ControlNet module" + suffix(n),
|
||||
choices=cn_module_choices,
|
||||
value="inpaint_global_harmonious",
|
||||
choices=["None"],
|
||||
value="None",
|
||||
visible=False,
|
||||
type="value",
|
||||
interactive=controlnet_exists,
|
||||
|
||||
@@ -29,7 +29,7 @@ cn_model_module = {
|
||||
"scribble": "t2ia_sketch_pidi",
|
||||
"lineart": "lineart_coarse",
|
||||
"openpose": "openpose_full",
|
||||
"tile": None,
|
||||
"tile": "tile_resample",
|
||||
}
|
||||
cn_model_regex = re.compile("|".join(cn_model_module.keys()))
|
||||
|
||||
@@ -60,7 +60,7 @@ class ControlNetExt:
|
||||
if (not self.cn_available) or model == "None":
|
||||
return
|
||||
|
||||
if module is None:
|
||||
if module is None or module == "None":
|
||||
for m, v in cn_model_module.items():
|
||||
if m in model:
|
||||
module = v
|
||||
|
||||
Reference in New Issue
Block a user