mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-03-13 01:10:01 +00:00
fix: change default values, names
This commit is contained in:
@@ -4,7 +4,7 @@ from .common import PredictOutput, get_models
|
||||
from .mediapipe import mediapipe_predict
|
||||
from .ultralytics import ultralytics_predict
|
||||
|
||||
AFTER_DETAILER = "After Detailer"
|
||||
AFTER_DETAILER = "ADetailer"
|
||||
|
||||
__all__ = [
|
||||
"__version__",
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "23.5.19"
|
||||
__version__ = "23.6.0.dev0"
|
||||
|
||||
@@ -13,7 +13,6 @@ from pydantic import (
|
||||
PositiveInt,
|
||||
confloat,
|
||||
constr,
|
||||
validator,
|
||||
)
|
||||
|
||||
|
||||
@@ -36,7 +35,7 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
||||
ad_model: str = "None"
|
||||
ad_prompt: str = ""
|
||||
ad_negative_prompt: str = ""
|
||||
ad_conf: confloat(ge=0.0, le=1.0) = 0.3
|
||||
ad_confidence: confloat(ge=0.0, le=1.0) = 0.3
|
||||
ad_mask_min_ratio: confloat(ge=0.0, le=1.0) = 0.0
|
||||
ad_mask_max_ratio: confloat(ge=0.0, le=1.0) = 1.0
|
||||
ad_dilate_erode: int = 32
|
||||
@@ -45,8 +44,8 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
||||
ad_mask_merge_invert: Literal["None", "Merge", "Merge and Invert"] = "None"
|
||||
ad_mask_blur: NonNegativeInt = 4
|
||||
ad_denoising_strength: confloat(ge=0.0, le=1.0) = 0.4
|
||||
ad_inpaint_full_res: bool = True
|
||||
ad_inpaint_full_res_padding: NonNegativeInt = 0
|
||||
ad_inpaint_only_masked: bool = True
|
||||
ad_inpaint_only_masked_padding: NonNegativeInt = 0
|
||||
ad_use_inpaint_width_height: bool = False
|
||||
ad_inpaint_width: PositiveInt = 512
|
||||
ad_inpaint_height: PositiveInt = 512
|
||||
@@ -58,17 +57,6 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
||||
ad_controlnet_model: constr(regex=r".*inpaint.*|^None$") = "None"
|
||||
ad_controlnet_weight: confloat(ge=0.0, le=1.0) = 1.0
|
||||
|
||||
@validator("ad_conf", pre=True)
|
||||
def check_ad_conf(cls, v: Any): # noqa: N805
|
||||
if not isinstance(v, (int, float)):
|
||||
try:
|
||||
v = int(v)
|
||||
except ValueError:
|
||||
v = float(v)
|
||||
if isinstance(v, int):
|
||||
v /= 100.0
|
||||
return v
|
||||
|
||||
@staticmethod
|
||||
def ppop(
|
||||
p: dict[str, Any],
|
||||
@@ -90,7 +78,6 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
||||
return {}
|
||||
|
||||
p = {name: getattr(self, attr) for attr, name in ALL_ARGS}
|
||||
p["ADetailer conf"] = int(p["ADetailer conf"] * 100)
|
||||
ppop = partial(self.ppop, p)
|
||||
|
||||
ppop("ADetailer prompt")
|
||||
@@ -100,7 +87,7 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
||||
ppop("ADetailer x offset", cond=0)
|
||||
ppop("ADetailer y offset", cond=0)
|
||||
ppop("ADetailer mask merge/invert", cond="None")
|
||||
ppop("ADetailer inpaint full", ["ADetailer inpaint padding"])
|
||||
ppop("ADetailer inpaint only masked", ["ADetailer inpaint padding"])
|
||||
ppop(
|
||||
"ADetailer use inpaint width/height",
|
||||
[
|
||||
@@ -148,7 +135,7 @@ _all_args = [
|
||||
("ad_model", "ADetailer model"),
|
||||
("ad_prompt", "ADetailer prompt"),
|
||||
("ad_negative_prompt", "ADetailer negative prompt"),
|
||||
("ad_conf", "ADetailer conf"),
|
||||
("ad_confidence", "ADetailer confidence"),
|
||||
("ad_mask_min_ratio", "ADetailer mask min ratio"),
|
||||
("ad_mask_max_ratio", "ADetailer mask max ratio"),
|
||||
("ad_x_offset", "ADetailer x offset"),
|
||||
@@ -157,8 +144,8 @@ _all_args = [
|
||||
("ad_mask_merge_invert", "ADetailer mask merge/invert"),
|
||||
("ad_mask_blur", "ADetailer mask blur"),
|
||||
("ad_denoising_strength", "ADetailer denoising strength"),
|
||||
("ad_inpaint_full_res", "ADetailer inpaint full"),
|
||||
("ad_inpaint_full_res_padding", "ADetailer inpaint padding"),
|
||||
("ad_inpaint_only_masked", "ADetailer inpaint only masked"),
|
||||
("ad_inpaint_only_masked_padding", "ADetailer inpaint padding"),
|
||||
("ad_use_inpaint_width_height", "ADetailer use inpaint width/height"),
|
||||
("ad_inpaint_width", "ADetailer inpaint width"),
|
||||
("ad_inpaint_height", "ADetailer inpaint height"),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import gradio as gr
|
||||
@@ -10,7 +11,7 @@ from adetailer.args import AD_ENABLE, ALL_ARGS, MASK_MERGE_INVERT
|
||||
from controlnet_ext import controlnet_exists, get_cn_inpaint_models
|
||||
|
||||
|
||||
class Widgets:
|
||||
class Widgets(SimpleNamespace):
|
||||
def tolist(self):
|
||||
return [getattr(self, attr) for attr in ALL_ARGS.attrs]
|
||||
|
||||
@@ -200,14 +201,14 @@ def detection(w: Widgets, n: int, is_img2img: bool):
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
w.ad_conf = gr.Slider(
|
||||
label="Detection model confidence threshold %" + suffix(n),
|
||||
minimum=0,
|
||||
maximum=100,
|
||||
step=1,
|
||||
value=30,
|
||||
w.ad_confidence = gr.Slider(
|
||||
label="Detection model confidence threshold" + suffix(n),
|
||||
minimum=0.0,
|
||||
maximum=1.0,
|
||||
step=0.01,
|
||||
value=0.3,
|
||||
visible=True,
|
||||
elem_id=eid("ad_conf"),
|
||||
elem_id=eid("ad_confidence"),
|
||||
)
|
||||
|
||||
with gr.Column(variant="compact"):
|
||||
@@ -262,7 +263,7 @@ def mask_preprocessing(w: Widgets, n: int, is_img2img: bool):
|
||||
minimum=-128,
|
||||
maximum=128,
|
||||
step=4,
|
||||
value=32,
|
||||
value=4,
|
||||
visible=True,
|
||||
elem_id=eid("ad_dilate_erode"),
|
||||
)
|
||||
@@ -303,26 +304,26 @@ def inpainting(w: Widgets, n: int, is_img2img: bool):
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column(variant="compact"):
|
||||
w.ad_inpaint_full_res = gr.Checkbox(
|
||||
label="Inpaint at full resolution " + suffix(n),
|
||||
w.ad_inpaint_only_masked = gr.Checkbox(
|
||||
label="Inpaint only masked" + suffix(n),
|
||||
value=True,
|
||||
visible=True,
|
||||
elem_id=eid("ad_inpaint_full_res"),
|
||||
)
|
||||
w.ad_inpaint_full_res_padding = gr.Slider(
|
||||
label="Inpaint at full resolution padding, pixels " + suffix(n),
|
||||
w.ad_inpaint_only_masked_padding = gr.Slider(
|
||||
label="Inpaint only masked padding, pixels" + suffix(n),
|
||||
minimum=0,
|
||||
maximum=256,
|
||||
step=4,
|
||||
value=0,
|
||||
value=32,
|
||||
visible=True,
|
||||
elem_id=eid("ad_inpaint_full_res_padding"),
|
||||
)
|
||||
|
||||
w.ad_inpaint_full_res.change(
|
||||
w.ad_inpaint_only_masked.change(
|
||||
gr_interactive,
|
||||
inputs=w.ad_inpaint_full_res,
|
||||
outputs=w.ad_inpaint_full_res_padding,
|
||||
inputs=w.ad_inpaint_only_masked,
|
||||
outputs=w.ad_inpaint_only_masked_padding,
|
||||
queue=False,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user