当前位置:   article > 正文

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 生成批次个数

  1. {
  2. "batch_size": 1,
  3. "cfg_scale": 7,
  4. "negative_prompt": "NSFW",
  5. "override_settings": {
  6. "sd_model_checkpoint": "anythingv5nijimix_25BEST.safetensors [8bc735ed57]"
  7. },
  8. "clip_skip": 1,
  9. "prompt": "full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>",
  10. "restore_faces": false,
  11. "sampler_index": "DPM++ SDE Karras",
  12. "sampler_name": "",
  13. "script_args": [],
  14. "seed": -1,
  15. "steps": 20,
  16. "tiling": false,
  17. "width": 512,
  18. "height": 512
  19. }

返回结果

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

data:image/png;base64,
  1. {
  2. "images": [
  3. "iVBORw0KGgoAAAANS"
  4. ],
  5. "parameters": {
  6. "prompt": "full body, a girl, blue hand, Long yellow hair, blue shoes, write background, <lora:20240320-1710939437372:1>",
  7. "negative_prompt": "NSFW",
  8. "styles": null,
  9. "seed": -1,
  10. "subseed": -1,
  11. "subseed_strength": 0,
  12. "seed_resize_from_h": -1,
  13. "seed_resize_from_w": -1,
  14. "sampler_name": "",
  15. "batch_size": 1,
  16. "n_iter": 1,
  17. "steps": 20,
  18. "cfg_scale": 7,
  19. "width": 512,
  20. "height": 512,
  21. "restore_faces": false,
  22. "tiling": false,
  23. "do_not_save_samples": false,
  24. "do_not_save_grid": false,
  25. "eta": null,
  26. "denoising_strength": null,
  27. "s_min_uncond": null,
  28. "s_churn": null,
  29. "s_tmax": null,
  30. "s_tmin": null,
  31. "s_noise": null,
  32. "override_settings": {
  33. "sd_model_checkpoint": "anythingv5nijimix_25BEST.safetensors [8bc735ed57]"
  34. },
  35. "override_settings_restore_afterwards": true,
  36. "refiner_checkpoint": null,
  37. "refiner_switch_at": null,
  38. "disable_extra_networks": false,
  39. "firstpass_image": null,
  40. "comments": null,
  41. "enable_hr": false,
  42. "firstphase_width": 0,
  43. "firstphase_height": 0,
  44. "hr_scale": 2,
  45. "hr_upscaler": null,
  46. "hr_second_pass_steps": 0,
  47. "hr_resize_x": 0,
  48. "hr_resize_y": 0,
  49. "hr_checkpoint_name": null,
  50. "hr_sampler_name": null,
  51. "hr_prompt": "",
  52. "hr_negative_prompt": "",
  53. "force_task_id": null,
  54. "sampler_index": "DPM++ SDE Karras",
  55. "script_name": null,
  56. "script_args": [],
  57. "send_images": true,
  58. "save_images": false,
  59. "alwayson_scripts": {},
  60. "infotext": null
  61. },
  62. "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\"}"
  63. }

具体可参考官方文档 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/445262
推荐阅读
相关标签
  

闽ICP备14008679号