AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

这篇具有很好参考价值的文章主要介绍了AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

资源

Docker镜像

docker pull darkroot1234/ayanami:latest

参考地址:

docker一键运行stable diffusion webui,常用插件和功能完备,获得镜像后可打包带走 - 哔哩哔哩

nvidia cuda 驱动

​​​​​​​Linux x64 (AMD64/EM64T) Display Driver | 525.116.04 | Linux 64-bit | NVIDIA

lora模型下载

热门Civitai LoRA模型下载第一批合集 Stable Diffusion WebUI - openAI

启动

docker run --gpus all -it -p 8888:8888 -p 7860:7860 -p 6666:22 --name ayanami --ipc=host darkroot1234/ayanami:latest

注意:启动时会访问公网,如果网络不通,会导致启动失败,注意看docker日志输出

docker cp 拷贝模型文件到容器/workspace/models/Stable-diffusion/目录下:chilloutmix_Ni.safetensors 

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

重启docker

docker restart ayanami

等待加载资源,打开浏览器,访问 http://127.0.0.1:7860

左上角选择放入的模型,采用该容器自带的参数,生成绫波丽

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

 AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

 修改参数,去掉CAD,机器人等信息

((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

http api

请求

通过观察浏览器请求,发现首次触发生成时,第一条请求predict/卡在pending状态,当渲染结束后,该请求响应出了图片地址

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

 复制出来的curl指令

curl 'http://127.0.0.1:7860/run/predict/' \
  -H 'Accept: */*' \
  -H 'Accept-Language: zh,en-US;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: _ga=GA1.1.1067480164.1660637226' \
  -H 'Origin: http://127.0.0.1:7860' \
  -H 'Referer: http://127.0.0.1:7860/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  --data-raw $'{"fn_index":102,"data":["((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,","","None","None",50,"Euler a",false,false,1,1,11,2083545561,-1,0,0,0,false,704,1024,false,0.7,0,0,"None",false,false,false,false,"","Seed","","Nothing","",true,false,false,null,"{\\"prompt\\": \\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\", \\"all_prompts\\": [\\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\"], \\"negative_prompt\\": \\"\\", \\"all_negative_prompts\\": [\\"\\"], \\"seed\\": 2083545561, \\"all_seeds\\": [2083545561], \\"subseed\\": 1093441852, \\"all_subseeds\\": [1093441852], \\"subseed_strength\\": 0, \\"width\\": 1024, \\"height\\": 704, \\"sampler_name\\": \\"Euler a\\", \\"cfg_scale\\": 11, \\"steps\\": 50, \\"batch_size\\": 1, \\"restore_faces\\": false, \\"face_restoration_model\\": null, \\"sd_model_hash\\": \\"8c3b86ce\\", \\"seed_resize_from_w\\": 0, \\"seed_resize_from_h\\": 0, \\"denoising_strength\\": null, \\"extra_generation_params\\": {}, \\"index_of_first_image\\": 0, \\"infotexts\\": [\\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2\\"], \\"styles\\": [\\"None\\", \\"None\\"], \\"job_timestamp\\": \\"20230511015740\\", \\"clip_skip\\": 2, \\"is_using_inpainting_conditioning\\": false}","<p>((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,<br>\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2</p><div class=\'performance\'><p class=\'time\'>Time taken: <wbr>24.71s</p><p class=\'vram\'>Torch active/reserved: 3573/4222 MiB, <wbr>Sys VRAM: 5882/5924 MiB (99.29%)</p></div>"],"session_hash":"t3m95wa7oj"}' \
  --compressed

其中我们填写的参数在data数组的第一段字符串参数内,即

((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,

第二个参数标识第二个输入框,我们没有输入。

响应

该请求会阻塞,直到渲染结束

{"data":[[{"name":"outputs/txt2img-images/00054-2083545561-((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,.png","data":null,"is_file":true}],"{\"prompt\": \"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\", \"all_prompts\": [\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\"], \"negative_prompt\": \"\", \"all_negative_prompts\": [\"\"], \"seed\": 2083545561, \"all_seeds\": [2083545561], \"subseed\": 881369708, \"all_subseeds\": [881369708], \"subseed_strength\": 0, \"width\": 1024, \"height\": 704, \"sampler_name\": \"Euler a\", \"cfg_scale\": 11, \"steps\": 50, \"batch_size\": 1, \"restore_faces\": false, \"face_restoration_model\": null, \"sd_model_hash\": \"8c3b86ce\", \"seed_resize_from_w\": 0, \"seed_resize_from_h\": 0, \"denoising_strength\": null, \"extra_generation_params\": {}, \"index_of_first_image\": 0, \"infotexts\": [\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2\"], \"styles\": [\"None\", \"None\"], \"job_timestamp\": \"20230511015814\", \"clip_skip\": 2, \"is_using_inpainting_conditioning\": false}","<p>((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,<br>\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2</p><div class='performance'><p class='time'>Time taken: <wbr>24.88s</p><p class='vram'>Torch active/reserved: 3573/3980 MiB, <wbr>Sys VRAM: 5665/5924 MiB (95.63%)</p></div>"],"is_generating":false,"duration":24.88272213935852,"average_duration":34.33394391720112}

其中name字段为生成图片的文件名,访问方式

http://127.0.0.1:7860/file=outputs/txt2img-images/00054-2083545561-((masterpiece)),%20((best%20quality)),((extremely%20detailed)),Ayanami%20Rei,beautiful%20face,Blue%20hair,Beautiful%20red%20eyes,.png

即:固定url前段

http://127.0.0.1:7860/file=

拼接上文件名,注意:文件名应当采用urlencode编码

效果

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

 该文件位于容器路径

/workspace/outputs/txt2img-images/ 

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

注意:该路径不会自动清理,如果大量生成,需要自行考虑把该目录挂载到分布式存储上,如glasterfs,需要自行设计清理程序。

进度查询

curl 'http://127.0.0.1:7860/run/predict/' \
  -H 'sec-ch-ua: "Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'Referer: http://127.0.0.1:7860/' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' \
  -H 'Content-Type: application/json' \
  --data-raw '{"fn_index":88,"data":[],"session_hash":"t3m95wa7oj"}' \
  --compressed

响应

进行中

{"data":["<span id='txt2img_progress_span' style='display: none'>1683771458.0030112</span><p><div class='progressDiv'><div class='progress' style=\"overflow:visible;width:98.0%;white-space:nowrap;\">&nbsp;&nbsp;98% ETA: 00s</div></div></p>",{"visible":false,"__type__":"update"},{"visible":false,"__type__":"update"},{"visible":false,"__type__":"update"}],"is_generating":false,"duration":0.0002410411834716797,"average_duration":0.0002521400164840813}

完成

{"data":["",{"visible":false,"__type__":"update"},{"visible":false,"__type__":"update"},{"visible":false,"__type__":"update"}],"is_generating":false,"duration":0.0005140304565429688,"average_duration":0.0002525332453730586}

api差异说明

fn_index data session_hash
生成api 102 必填 必填
查询api 88 留空 必填(保持与生成api一致)

http api调佣测试

主要参数修改为

((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,

完整curl指令

curl 'http://127.0.0.1:7860/run/predict/' \
  -H 'Accept: */*' \
  -H 'Accept-Language: zh,en-US;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: _ga=GA1.1.1067480164.1660637226' \
  -H 'Origin: http://127.0.0.1:7860' \
  -H 'Referer: http://127.0.0.1:7860/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  --data-raw $'{"fn_index":102,"data":["((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,","","None","None",50,"Euler a",false,false,1,1,11,2083545561,-1,0,0,0,false,704,1024,false,0.7,0,0,"None",false,false,false,false,"","Seed","","Nothing","",true,false,false,null,"{\\"prompt\\": \\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\", \\"all_prompts\\": [\\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\"], \\"negative_prompt\\": \\"\\", \\"all_negative_prompts\\": [\\"\\"], \\"seed\\": 2083545561, \\"all_seeds\\": [2083545561], \\"subseed\\": 1093441852, \\"all_subseeds\\": [1093441852], \\"subseed_strength\\": 0, \\"width\\": 1024, \\"height\\": 704, \\"sampler_name\\": \\"Euler a\\", \\"cfg_scale\\": 11, \\"steps\\": 50, \\"batch_size\\": 1, \\"restore_faces\\": false, \\"face_restoration_model\\": null, \\"sd_model_hash\\": \\"8c3b86ce\\", \\"seed_resize_from_w\\": 0, \\"seed_resize_from_h\\": 0, \\"denoising_strength\\": null, \\"extra_generation_params\\": {}, \\"index_of_first_image\\": 0, \\"infotexts\\": [\\"((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,\\\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2\\"], \\"styles\\": [\\"None\\", \\"None\\"], \\"job_timestamp\\": \\"20230511015740\\", \\"clip_skip\\": 2, \\"is_using_inpainting_conditioning\\": false}","<p>((masterpiece)), ((best quality)),((extremely detailed)),Ayanami Rei,beautiful face,Blue hair,Beautiful red eyes,<br>\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2</p><div class=\'performance\'><p class=\'time\'>Time taken: <wbr>24.71s</p><p class=\'vram\'>Torch active/reserved: 3573/4222 MiB, <wbr>Sys VRAM: 5882/5924 MiB (99.29%)</p></div>"],"session_hash":"t3m95wa7oj"}' \
  --compressed

响应(约15秒)

{"data":[[{"name":"outputs/txt2img-images/00055-2083545561-((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,.png","data":null,"is_file":true}],"{\"prompt\": \"((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,\", \"all_prompts\": [\"((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,\"], \"negative_prompt\": \"\", \"all_negative_prompts\": [\"\"], \"seed\": 2083545561, \"all_seeds\": [2083545561], \"subseed\": 501878245, \"all_subseeds\": [501878245], \"subseed_strength\": 0, \"width\": 1024, \"height\": 704, \"sampler_name\": \"Euler a\", \"cfg_scale\": 11, \"steps\": 50, \"batch_size\": 1, \"restore_faces\": false, \"face_restoration_model\": null, \"sd_model_hash\": \"8c3b86ce\", \"seed_resize_from_w\": 0, \"seed_resize_from_h\": 0, \"denoising_strength\": null, \"extra_generation_params\": {}, \"index_of_first_image\": 0, \"infotexts\": [\"((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,\\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2\"], \"styles\": [\"None\", \"None\"], \"job_timestamp\": \"20230511021329\", \"clip_skip\": 2, \"is_using_inpainting_conditioning\": false}","<p>((masterpiece)), ((best quality)),((extremely detailed)),beautiful face,Beautiful eyes,<br>\nSteps: 50, Sampler: Euler a, CFG scale: 11, Seed: 2083545561, Size: 1024x704, Model hash: 8c3b86ce, Clip skip: 2</p><div class='performance'><p class='time'>Time taken: <wbr>24.41s</p><p class='vram'>Torch active/reserved: 3573/4222 MiB, <wbr>Sys VRAM: 5853/5924 MiB (98.8%)</p></div>"],"is_generating":false,"duration":24.41366720199585,"average_duration":33.62535272325788}

拼接出图片地址

http://127.0.0.1:7860/file=outputs/txt2img-images/00055-2083545561-((masterpiece)),%20((best%20quality)),((extremely%20detailed)),beautiful%20face,Beautiful%20eyes,.png

访问

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口

处理时,gpu负载

AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口文章来源地址https://www.toymoban.com/news/detail-478659.html

到了这里,关于AI画图 Ubuntu 20.04.5 LTS x86_64 Docker stable diffusion webui 及 http api接口的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • SPEC CPU 2017 x86_64 Ubuntu 22.04 LTS LLVM 16.0.6 编译 intrate intspeed

    编译成功日志 安装openmp,其中有日志 -- Installing: /usr/local/lib/libomp.so  

    2024年02月15日
    浏览(81)
  • Ubuntu20.04本地部署Stable-Diffusion-webui AI绘画环境

    最近AI绘画很火,所以想在本地部署个环境体验一下。原本打算在Windows下安装,网上有很多教程,也有很多大佬做了整合包,可是我的Windows系统下的显卡驱动版本太低,也没法升级,只能装CUDA9,导致安装torch会出现问题。所以考虑在Ubuntu下安装,参考了几篇文章,所幸也安

    2023年04月11日
    浏览(70)
  • Install Stable Diffusion WebUI on Ubuntu 22.04.2 LTS

    OS:Ubuntu 22.04 LTS Kernel:5.15.0-60-generic CPU: Intel(R) Xeon(R) Gold 6278C CPU @ 2.60GHz, 8vCPUs  GPU: 1 * NVIDIA V100-PCIe-32G  RAM: 64GB system disk:512 GiB data disk: 2048 GiB Stable Diffusion WebUI version:0cc0ee1 (2023/2/20) Go to HuggingFace or Civitai to find a model. Use wget command to download the model Here are some good mode

    2024年02月15日
    浏览(28)
  • Stable Diffusion WebUI Ubuntu 22.04 LTS RTX2060 6G 极限显存出图

    模型   默认选中  chilloutmix_Ni.safetensors,重启webui.sh进程 正向词 反向词 其他 出图    显卡还能剩余不到200M。

    2024年02月13日
    浏览(33)
  • Ubuntu20.04_x86交叉编译aarch64版本的tslib1.22步骤

    编译环境:小米笔记本+Windows10+VMware17 +Ubuntu20.04虚拟机 编译目标:需要生成aarch64环境下对应的触摸屏驱动。 编译步骤: 1、下载aarch64-linux-gnu编译器,下载地址为:https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.x

    2024年02月16日
    浏览(38)
  • Ubuntu搭建AI画图工具stable diffusion-webui

    Ubuntu搭建 安装依赖项 安装以下依赖项: 下载并安装WebUI 进入您想要安装WebUI的目录,并执行以下命令: 运行WebUI 执行以下命令来运行WebUI: 配置选项 检查webui-user.sh文件以获取更多配置选项。

    2024年02月05日
    浏览(34)
  • Linux(7)Ubuntu20.04 arm64安装Docker

    vi /etc/apt/sources.list 这个命令后面跟了几个软件包的名字,它们分别是: apt-transport-https:这个软件包允许apt使用HTTPS协议来访问软件源。 ca-certificates:这个软件包提供了一些受信任的证书颁发机构的证书,用来验证HTTPS连接的安全性。 curl:这个软件包提供了一个命令行工具,

    2024年02月10日
    浏览(46)
  • Ubuntu20.4 docker运行stable diffusion webui

    系统环境 ubuntu20.04 nvida cuda显卡驱动 默认已经安装成功 更新系统依赖: 确认是否之前安装过docker并卸载: 启动并查看docker运行状态: 注:这一部步基本可以忽略,因为没有使用国外dockerhub镜像! 安装 nvidia-docker2 包 安装完成后需要重启docker: 能输出cuda相关信息安装成功:

    2024年02月09日
    浏览(29)
  • Ubuntu 20.04 LTS 安装教程

    官方桌面版下载:https://cn.ubuntu.com/download/desktop,进入下载页面后,通常我们并不想安装最新的Ubuntu版本,那么需要找到其它版本的下载链接,如下图的红色框。如果要安装最新版,直接点击下载下图中的绿色框即可   由于该教程主要是安装 Ubuntu 20.04 版本,所以点击【上图

    2024年02月17日
    浏览(58)
  • Ubuntu 20.04 LTS 修改IP地址

    在Ubuntu20.04中,传统的配置/etc/network/interfaces已无效!需要打开 yaml 文件,在 /etc/netplan 文件夹下,不同机器的文件名不一样。通过编辑yaml文件进行配置(一定注意缩进格式),如下: 注意: 这是修改为静态IP的方式,所以上面的 DHCP4:最好改成 FALSE ,防止自动获取IP,导致

    2024年02月02日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包