最近使用 stable-diffusion-webui 的 api 接口,进行图片生成,使用的一些参数经常找不到是什么,在这里记录一下。

# 插件参数

使用第三方插件需要调用参数时,通过 alwayson_scripts 字段来发送配置:

{
        "prompt": "a cinematic shot of an impressive ants war, ant melee, armageddon",
        "sampler_name": "Euler",
        "alwayson_scripts": {
            "controlnet": {
            "args": [
                {
                "input_image": "base64...",
                "model": "diff_control_sd15_depth_fp16 [978ef0a1]"
                }
            ]
            }
        }
    }

参见 https://github.com/Mikubill/sd-webui-controlnet/wiki/API#web-api

至于具体的第三方插件支持啥参数,则需要查找对应的文档说明。

# /sdapi/v1/*2img 参数

文生图或者图生图等,参数都可以在其 api 文档中看到,http://127.0.0.1:7860/docs

这里的主要问题要设置某些属性可能在参数里没有,比如每次调用设置 CKPT 切换模型。后在 issue 中找到,新版本已支持通过设置 override_settings 字段来进行覆盖配置,且这样的配置只针对这一次的调用,而不像通过 POST /sdapi/v1/options 直接设置属性那样是保存了让每次都生效的。

相关的可以覆写的属性,就是来自于 http://127.0.0.1:7860/sdapi/v1/options 所返回的属性。

# 获取 LORA 列表

使用 lora 时需要知道已经安装了哪些 lora ,这里调用 http://127.0.0.1:7860/sdapi/v1/loras 接口查看

# 总结

总结一下常用的接口

功能地址
查询模型http://127.0.0.1:7860/sdapi/v1/sd-models
查询 lorahttp://127.0.0.1:7860/sdapi/v1/loras
查询进度http://127.0.0.1:7860/sdapi/v1/loras
采样器http://127.0.0.1:7860/sdapi/v1/options
controlnet 模型http://127.0.0.1:7860/controlnet/model_list

其实自带的接口文档里基本也能找到 http://127.0.0.1:7860/docs ,除了某些特殊的功能不一定想到怎么用,还是得找找其他文档或 issue 之类的。

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

HuaLin 微信支付

微信支付

HuaLin 支付宝

支付宝