Stable Diffusion API POST请求中ADetailer参数配置问题求助
Stable Diffusion API 配置 ADetailer 正确姿势
在调用Stable Diffusion API做图生图时,尝试在POST请求Payload中加入ADetailer参数,但多种写法都未被SD识别,生成的图片信息里也没有ADetailer相关记录。以下是试过的无效Payload代码:
payload = { "init_images": [encoded_string], "prompt": pr, "denoising_strength": 0.4, "negative_prompt": npr, "batch_size": 1, "steps": 22, "cfg_scale": 7, "width": np.array(img).shape[1], "height": np.array(img).shape[0], #"ADetailer": [{"model": "face_yolov8n.pt"}], #"adetailer": [{"model": "face_yolov8n.pt"}], #"ADetailer model": "face_yolov8n.pt", #"adetailer model": "face_yolov8n.pt", "alwayson_scripts": { "ADetailer": { "args": [{ "model": "face_yolov8n.pt", #"denoising_strength": 0.2 } ] }, "adetailer": { "args": [{"model": "face_yolov8n.pt", 'enable': True}, ] }, "adetailer": {"model": "face_yolov8n.pt", 'enable': True}, "controlnet": { "args": [ { "input_image": encoded_string, "module": "canny", #'preprocessor': 'canny', "model": "control_v11p_sd15_canny_fp16 [b18e0966]", }, { "input_image": encoded_string, #"module": "lineart_standard (from white bg & black line)", 'preprocessor': 'lineart_standard (from white bg & black line)', "model": "control_v11p_sd15_lineart_fp16 [5c23b17d]", #"weight": 0.5 }, { #'preprocessor': 'reference_only', "input_image": reference, "module": "reference_only" } ] }, } }
错误原因分析
- Python字典中重复定义
adetailer键,会导致前面的配置被最后一个覆盖,直接失效 - ADetailer脚本名称严格区分大小写,必须用
"ADetailer"作为键名,小写的"adetailer"无法被识别 args必须是数组格式,不能直接传递单个对象- 部分配置缺少
enable: true参数,默认可能未启用ADetailer功能
正确的Payload配置
payload = { "init_images": [encoded_string], "prompt": pr, "denoising_strength": 0.4, "negative_prompt": npr, "batch_size": 1, "steps": 22, "cfg_scale": 7, "width": np.array(img).shape[1], "height": np.array(img).shape[0], "alwayson_scripts": { # 仅保留一个ADetailer配置,键名严格使用大写开头 "ADetailer": { "args": [ { "model": "face_yolov8n.pt", "enable": True, # 必须显式启用 "denoising_strength": 0.2, # 可选:修复降噪强度 "confidence": 0.3, # 可选:人脸检测置信度阈值 "dilate_erode": 4, # 可选:Mask膨胀/腐蚀程度 "mask_blur": 4, # 可选:Mask模糊度 "inpaint_only_masked": True, # 可选:仅修复Mask覆盖区域 "inpaint_padding": 32 # 可选:修复区域扩展 padding 值 } ] }, "controlnet": { "args": [ { "input_image": encoded_string, "module": "canny", "model": "control_v11p_sd15_canny_fp16 [b18e0966]", }, { "input_image": encoded_string, "preprocessor": "lineart_standard (from white bg & black line)", "model": "control_v11p_sd15_lineart_fp16 [5c23b17d]", }, { "input_image": reference, "module": "reference_only" } ] }, } }
配置完成后,生成的图片信息中会出现类似ADetailer model: face_yolov8n.pt, ADetailer confidence: 0.3...的记录,说明ADetailer已正常生效。
内容的提问来源于stack exchange,提问作者Roman Zakharov
相关产品推荐
相关产品推荐

