Stable Diffusion支持http的api,开启方式有两种:
1、webui.bat 启动命令后面增加一个--api
2、打开webui-user.bat文件,将里面的set COMMANDLINE_ARGS=--api 这样运行就是启动api,启动后通过 http://127.0.0.1:7860/docs)就能看到api文档了。
import requests import base64 # Define the URL and the payload to send. url = "http://127.0.0.1:7860" payload = { "prompt": "puppy dog", "steps": 5 } # Send said payload to said URL through the API. response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload) r = response.json() # Decode and save the image. with open("output.png", 'wb') as f: f.write(base64.b64decode(r['images'][0]))参考:https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API
网友回复
UEFI与Legacy启动有啥不同?
可在u盘启动的开源匿名操作系统有哪些?
Pyloid与Pywebview打包生成桌面应用区别?
win10的iso镜像如何通过u盘来安装?
如何解决输入sora2邀请码报错:Sora is not available in The Netherlands yet
在哪可免费白嫖使用sora2生成视频?
php如何结合openai兼容的embedding向量化api实现语义化模糊关键词搜索匹配?
python如何结合qwen embedding向量化api实现语义化模糊关键词搜索匹配?
如何利用ai翻拍创作热门视频影视电视剧赚钱?
如何去除sora2生成的视频水印?