本地部署之后通过 localhost:7860/docs可以看到但是如果无法访问,可以直接看github或是其他的文件,通过写这篇文章记录一下自己工作中使用到的txt2img这个API参数类型。
由于我更多偏向建筑结构外立面渲染所以很多人物或是细节不需要,会少很多的设置。
更详细的可以参照这个文章 全网最全stable diffusion webui API调用示例,包含controlneth和segment anything的API(附json示例)
在线查看base64的网站 :https://www.lddgo.net/convert/base64-to-image
在线将本地图片转换成base64的网站: https://www.lddgo.net/convert/imagebasesix
sd api github 介绍页 :https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API
controlNet github api 介绍页 : https://github.com/Mikubill/sd-webui-controlnet/wiki/API
我使用的ui是绘世
由于是中文界面加上是刚开始开发sd所以导致一些API的参数不是很明确,controlNet的github介绍的比较详细,会有参数的示例能快速理解。
下面是我的SD基本配置,通过先手动测试一下整体的输出效果,开发人员同步一下配置即可。

**controlnet 控制区域**

**webui 输出**

通过上面你的配置,在sd里面的配置可以变成下面你的参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| { "prompt": "(ultra-realistic industrial daylight rendering:1.6)", #提示词 "negative_prompt": "curved surfaces", #负向提示词 "seed": -1, #随机种子数 "batchSize": 1, #生成批次 "iterations": 1, # 批次数量 "steps": 20, # 迭代步数 "cfg_scale": 7, # 提示词引导系数 "width": 1024, # 宽度 "height": 512, # 高度 "override_settings": { "sd_model_checkpoint": "realvisxlV50_v50Bakedvae.safetensors [6a35a78557]", "sd_vae": "None" } # 覆盖之前的web设置,例如单个请求的模型或CLIP跳过 , 如果vae没有特殊情况会设置成automatic,如果制定会报错RuntimeError: Expected all tensors to be on the same device, but found at least two devices , "sampler_name": "DPM++ 2M", #采样方法 "alwayson_scripts" : { "controlnet": { "args" : [ { "enabled" : true , # 开启 "input_image" : "base64 , 新手不要直接传路径" , # 输入的图,要求base64格式 "module" : "lineart_standard (from white bg & black line)", # 预处理器 prepeocesser "model" : "controlnet++_union_sdxl_promax [9460e4db]" , # controlnet model "weight" : 1.4, # 权重系数 "invert_image" : false , # 反转 "resize_mode" : "Crop and Resize" , # 缩放模式,这里不清楚的话可以生成一下图片在图片下方找到resize mode标识,或是去github查看但是github上面并没有这个模式,所以最好以ui显示为准 "lowram" : false, # 低显存 "processor_res" : 512, # 预处理器分辨率 "threshold_a": 0.5, # 阈值 a "threshold_b": 0.5, # 阈值 b "pixel_perfect" : true, # 完美像素模式 "control_mode" : "My prompt is more important", # 控制模式 , 此处可以看github介绍使用文字或是数字都可以,但是我这里使用数字报错 "starting_control_step": 0, # 引导介入时机 "ending_control_step": 0.9, # 引导终止时机 "process_complete" : true , # run proprocess按钮
"control_type" : "lineart" # 控制类型 } ] } }
}
|