Stable Diffusion之API接口调用

Stable Diffusion之API接口调用

    正在检查是否收录...

1、开启api调用模式

开启api模式,关闭可视化窗口,并且建议关闭登录权限(详细查看文章最后Stable Diffusion之Ubuntu下部署-CSDN博客)

./webui.sh  --disable-safe-unpickle  --api --nowebui

2、查看接口列表 

访问对应的网页地址 http://192.168.xx.xx:7860/docs#

3、text2img接口调用

#接口地址

http://192.168.xx.xx:9876/sdapi/v1/txt2img

参数内容

application/json

batch_size 生成批次个数

{ "batch_size": 1, "cfg_scale": 7, "negative_prompt": "NSFW", "override_settings": { "sd_model_checkpoint": "anythingv5nijimix_25BEST.safetensors [8bc735ed57]" }, "clip_skip": 1, "prompt": "full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>", "restore_faces": false, "sampler_index": "DPM++ SDE Karras", "sampler_name": "", "script_args": [], "seed": -1, "steps": 20, "tiling": false, "width": 512, "height": 512 }

返回结果

其中 images[] 数据就是我们需要的图片base64字符串,补充前缀用于保存、浏览器查看

data:image/png;base64, 
{ "images": [ "iVBORw0KGgoAAAANS" ], "parameters": { "prompt": "full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>", "negative_prompt": "NSFW", "styles": null, "seed": -1, "subseed": -1, "subseed_strength": 0, "seed_resize_from_h": -1, "seed_resize_from_w": -1, "sampler_name": "", "batch_size": 1, "n_iter": 1, "steps": 20, "cfg_scale": 7, "width": 512, "height": 512, "restore_faces": false, "tiling": false, "do_not_save_samples": false, "do_not_save_grid": false, "eta": null, "denoising_strength": null, "s_min_uncond": null, "s_churn": null, "s_tmax": null, "s_tmin": null, "s_noise": null, "override_settings": { "sd_model_checkpoint": "anythingv5nijimix_25BEST.safetensors [8bc735ed57]" }, "override_settings_restore_afterwards": true, "refiner_checkpoint": null, "refiner_switch_at": null, "disable_extra_networks": false, "firstpass_image": null, "comments": null, "enable_hr": false, "firstphase_width": 0, "firstphase_height": 0, "hr_scale": 2, "hr_upscaler": null, "hr_second_pass_steps": 0, "hr_resize_x": 0, "hr_resize_y": 0, "hr_checkpoint_name": null, "hr_sampler_name": null, "hr_prompt": "", "hr_negative_prompt": "", "force_task_id": null, "sampler_index": "DPM++ SDE Karras", "script_name": null, "script_args": [], "send_images": true, "save_images": false, "alwayson_scripts": {}, "infotext": null }, "info": "{\"prompt\": \"full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>\", \"all_prompts\": [\"full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>\"], \"negative_prompt\": \"NSFW\", \"all_negative_prompts\": [\"NSFW\"], \"seed\": 2807822694, \"all_seeds\": [2807822694], \"subseed\": 1914786312, \"all_subseeds\": [1914786312], \"subseed_strength\": 0, \"width\": 512, \"height\": 512, \"sampler_name\": \"DPM++ SDE Karras\", \"cfg_scale\": 7.0, \"steps\": 20, \"batch_size\": 1, \"restore_faces\": false, \"face_restoration_model\": null, \"sd_model_name\": \"anythingv5nijimix_25BEST\", \"sd_model_hash\": \"8bc735ed57\", \"sd_vae_name\": null, \"sd_vae_hash\": null, \"seed_resize_from_w\": -1, \"seed_resize_from_h\": -1, \"denoising_strength\": null, \"extra_generation_params\": {\"Lora hashes\": \"20240320-1710939437372: ff34c35aff98\"}, \"index_of_first_image\": 0, \"infotexts\": [\"full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>\\nNegative prompt: NSFW\\nSteps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7.0, Seed: 2807822694, Size: 512x512, Model hash: 8bc735ed57, Model: anythingv5nijimix_25BEST, Lora hashes: \\\"20240320-1710939437372: ff34c35aff98\\\", Version: v1.8.0\"], \"styles\": [], \"job_timestamp\": \"20240413153633\", \"clip_skip\": 1, \"is_using_inpainting_conditioning\": false, \"version\": \"v1.8.0\"}" }

具体可参考官方文档 

prompt2024sfwnsfwapiscriptstoreideclipromptsclipwebuiwebpngjsonapi调用diffusion可视化appstable diffusion
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-16223.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

AIGC简介:如何利用人工智能进行内容生成

上一篇

AI绘画Stable Diffusion 【模型推荐】超逼真!专注创造极其真实的人像摄影作品大模型AWPortrait

下一篇
  • 复制图片
按住ctrl可打开默认菜单