Ai
1 Star 0 Fork 0

开源参考/sd-webui-replacer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
apiExample.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
Andray 提交于 2024-03-26 17:33 +08:00 . add queue_lock in api
#!/bin/python3
from PIL import Image
import requests, base64, io, argparse
SD_WEBUI = 'http://127.0.0.1:7860'
parser = argparse.ArgumentParser()
parser.add_argument('filename')
args = parser.parse_args()
with open(args.filename, 'rb') as image_file:
base64_image = base64.b64encode(image_file.read()).decode('utf-8')
payload = {
"input_image": base64_image,
"detection_prompt": "background",
"positive_prompt": "waterfall",
"sam_model_name": "sam_hq_vit_h.pth",
"dino_model_name": "GroundingDINO_SwinB (938MB)",
"use_hires_fix": True,
"scripts": { # "scripts" has the same format with "alwayson_scripts" in /sdapi/v1/txt2img
"controlnet": {
"args": [
{ # See ControlNetUnit dataclass for all possible fields
"enabled": True,
"module": "openpose_full",
"model": "control_v11p_sd15_openpose [cab727d4]",
},
]
},
"soft inpainting": { # Default args from UI, recommended hight "mask_blur"
"args": [False, 1, 0.5, 4, 0, 1, 2]
},
},
}
response = requests.post(url=f'{SD_WEBUI}/replacer/replace', json=payload)
if response.status_code == 200:
response = response.json()
if response['info']:
print(response['info'])
if response['image']:
Image.open(io.BytesIO(base64.b64decode(response['image']))).show()
else:
print(response.json())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/open_source_reference/sd-webui-replacer.git
git@gitee.com:open_source_reference/sd-webui-replacer.git
open_source_reference
sd-webui-replacer
sd-webui-replacer
master

搜索帮助