mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-03-13 17:30:01 +00:00
fix: apply lint, C901
This commit is contained in:
@@ -270,7 +270,12 @@ class AfterDetailerScript(scripts.Script):
|
||||
return all_prompts[j]
|
||||
|
||||
def _get_prompt(
|
||||
self, ad_prompt: str, all_prompts: list[str], i: int, default: str, replacements: list[tuple[str,str]]
|
||||
self,
|
||||
ad_prompt: str,
|
||||
all_prompts: list[str],
|
||||
i: int,
|
||||
default: str,
|
||||
replacements: list[tuple[str, str]],
|
||||
) -> list[str]:
|
||||
prompts = re.split(r"\s*\[SEP\]\s*", ad_prompt)
|
||||
blank_replacement = self.prompt_blank_replacement(all_prompts, i, default)
|
||||
@@ -286,9 +291,15 @@ class AfterDetailerScript(scripts.Script):
|
||||
def get_prompt(self, p, args: ADetailerArgs) -> tuple[list[str], list[str]]:
|
||||
i = p._ad_idx
|
||||
|
||||
prompt = self._get_prompt(args.ad_prompt, p.all_prompts, i, p.prompt, args.ad_prompt_replacements)
|
||||
prompt = self._get_prompt(
|
||||
args.ad_prompt, p.all_prompts, i, p.prompt, args.ad_prompt_replacements
|
||||
)
|
||||
negative_prompt = self._get_prompt(
|
||||
args.ad_negative_prompt, p.all_negative_prompts, i, p.negative_prompt, args.ad_prompt_replacements
|
||||
args.ad_negative_prompt,
|
||||
p.all_negative_prompts,
|
||||
i,
|
||||
p.negative_prompt,
|
||||
args.ad_prompt_replacements,
|
||||
)
|
||||
|
||||
return prompt, negative_prompt
|
||||
@@ -787,6 +798,23 @@ def on_ui_settings():
|
||||
# xyz_grid
|
||||
|
||||
|
||||
def set_value(p, x, xs, *, field: str):
|
||||
if not hasattr(p, "_ad_xyz"):
|
||||
p._ad_xyz = {}
|
||||
p._ad_xyz[field] = x
|
||||
|
||||
|
||||
def search_and_replace_prompt(p, x, xs, replace_in_main_prompt):
|
||||
if replace_in_main_prompt:
|
||||
p.prompt = p.prompt.replace(xs[0], x)
|
||||
p.negative_prompt = p.negative_prompt.replace(xs[0], x)
|
||||
if not hasattr(p, "_ad_xyz"):
|
||||
p._ad_xyz = {}
|
||||
if "ad_prompt_replacements" not in p._ad_xyz:
|
||||
p._ad_xyz["ad_prompt_replacements"] = []
|
||||
p._ad_xyz["ad_prompt_replacements"].append((xs[0], x))
|
||||
|
||||
|
||||
def make_axis_on_xyz_grid():
|
||||
xyz_grid = None
|
||||
for script in scripts.scripts_data:
|
||||
@@ -800,21 +828,6 @@ def make_axis_on_xyz_grid():
|
||||
model_list = ["None", *model_mapping.keys()]
|
||||
samplers = [sampler.name for sampler in all_samplers]
|
||||
|
||||
def set_value(p, x, xs, *, field: str):
|
||||
if not hasattr(p, "_ad_xyz"):
|
||||
p._ad_xyz = {}
|
||||
p._ad_xyz[field] = x
|
||||
|
||||
def search_and_replace_prompt(p, x, xs, replace_in_main_prompt):
|
||||
if replace_in_main_prompt:
|
||||
p.prompt = p.prompt.replace(xs[0], x)
|
||||
p.negative_prompt = p.negative_prompt.replace(xs[0], x)
|
||||
if not hasattr(p, "_ad_xyz"):
|
||||
p._ad_xyz = {}
|
||||
if not "ad_prompt_replacements" in p._ad_xyz:
|
||||
p._ad_xyz["ad_prompt_replacements"] = []
|
||||
p._ad_xyz["ad_prompt_replacements"].append((xs[0],x))
|
||||
|
||||
axis = [
|
||||
xyz_grid.AxisOption(
|
||||
"[ADetailer] ADetailer model 1st",
|
||||
@@ -840,7 +853,7 @@ def make_axis_on_xyz_grid():
|
||||
xyz_grid.AxisOption(
|
||||
"[ADetailer] Prompt S/R (AD 1st and main prompt)",
|
||||
str,
|
||||
partial(search_and_replace_prompt, replace_in_main_prompt=True)
|
||||
partial(search_and_replace_prompt, replace_in_main_prompt=True),
|
||||
),
|
||||
xyz_grid.AxisOption(
|
||||
"[ADetailer] Mask erosion / dilation 1st",
|
||||
|
||||
Reference in New Issue
Block a user