From 0aa5b690234e6018aebdbd2af162c73a3b049cc3 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:41:56 +1100 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=9C=A8sdwebui=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E6=B7=BB=E5=8A=A0alwayson=5Fscripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如: [sdwebui.alwayson_scripts.ADetailer] args = [{ad_model = "face_yolov8n.pt"},{ad_model = "hand_yolov8n.pt"}] --- config.py | 9 +++++++++ drawing/sdwebui.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 1886175c..b09cbde9 100644 --- a/config.py +++ b/config.py @@ -517,6 +517,12 @@ class Ratelimit(BaseModel): class SDWebUI(BaseModel): + class ScriptArg(BaseModel): + ad_model: str + + class ScriptConfig(BaseModel): + args: List['SDWebUI.ScriptArg'] + api_url: str """API 基地址,如:http://127.0.0.1:7890""" prompt_prefix: str = 'masterpiece, best quality, illustration, extremely detailed 8K wallpaper' @@ -534,6 +540,7 @@ class SDWebUI(BaseModel): cfg_scale: float = 7.5 restore_faces: bool = False authorization: str = '' + alwayson_scripts: Dict[str, 'SDWebUI.ScriptConfig'] = {} """登录api的账号:密码""" timeout: float = 10.0 @@ -541,6 +548,8 @@ class SDWebUI(BaseModel): class Config(BaseConfig): extra = Extra.allow +SDWebUI.update_forward_refs() +SDWebUI.ScriptConfig.update_forward_refs() class Config(BaseModel): diff --git a/drawing/sdwebui.py b/drawing/sdwebui.py index e07107db..c2305e73 100644 --- a/drawing/sdwebui.py +++ b/drawing/sdwebui.py @@ -41,7 +41,8 @@ async def text_to_img(self, prompt): 'tiling': 'false', 'negative_prompt': config.sdwebui.negative_prompt, 'eta': 0, - 'sampler_index': config.sdwebui.sampler_index + 'sampler_index': config.sdwebui.sampler_index, + 'alwayson_scripts': {} } for key, value in config.sdwebui.dict(exclude_none=True).items():