Files
chatgpt-on-wechat/plugins/sdwebui/readme.md
2023-03-14 00:49:28 +08:00

63 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
本插件用于将画图请求转发给stable diffusion webui
使用前先安装stable diffusion webui并在它的启动参数中添加 "--api"
具体参考(https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API)
请**安装**本插件的依赖包```webuiapi```
```
```pip install webuiapi```
```
请将```config.json.template```复制为```config.json```,并修改其中的参数和规则
用户的画图请求格式为:
```
<画图触发词><关键词1> <关键词2> ... <关键词n>:<prompt>
```
本插件会对画图触发词后的关键词进行逐个匹配,如果触发了规则中的关键词,则会在画图请求中重载对应的参数。
规则会按顺序匹配每个关键词最多匹配到1次如果有重复的参数则以最后一个为准
第一个"**:**"号之后的内容会作为附加的**prompt**接在最终的prompt后
例如: 画横版 高清 二次元:cat
会触发三个关键词 "横版", "高清", "二次元"prompt为"cat"
若默认参数是:
```
"width": 512,
"height": 512,
"enable_hr": false,
"prompt": "8k"
"negative_prompt": "nsfw",
"sd_model_checkpoint": "perfectWorld_v2Baked"
```
"横版"触发的规则参数为:
```
"width": 640,
"height": 384,
```
"高清"触发的规则参数为:
```
"enable_hr": true,
"hr_scale": 1.6,
```
"二次元"触发的规则参数为:
```
"negative_prompt": "(low quality, worst quality:1.4),(bad_prompt:0.8), (monochrome:1.1), (greyscale)",
"steps": 20,
"prompt": "masterpiece, best quality",
"sd_model_checkpoint": "meinamix_meinaV8"
```
最后将第一个":"后的内容cat连接在prompt后得到最终参数为:
```
"width": 640,
"height": 384,
"enable_hr": true,
"hr_scale": 1.6,
"negative_prompt": "(low quality, worst quality:1.4),(bad_prompt:0.8), (monochrome:1.1), (greyscale)",
"steps": 20,
"prompt": "masterpiece, best quality, cat",
"sd_model_checkpoint": "meinamix_meinaV8"
```
PS: 参数分为两部分,
一部分是params为画画的参数;参数名**必须**与webuiapi包中[txt2img api](https://github.com/mix1009/sdwebuiapi/blob/fb2054e149c0a4e25125c0cd7e7dca06bda839d4/webuiapi/webuiapi.py#L163)的参数名一致
另一部分是options指sdwebui的设置使用的模型和vae需要写在里面。它和http://127.0.0.1:7860/sdapi/v1/options所返回的键一致。