AIGC 文生图及 stable diffusion webui 练习笔记

文章目录

  • 环境要求
  • 一. stable-diffusion-webui 安装
    • windows/linux 安装
    • docker 容器内安装
  • 二. 运行 web-ui
    • 插件安装
      • civitai helper
      • additional network
  • 三. 常用模型
    • stable diffusion 模型
      • chilloutmix
    • LoRA 模型
      • Korean Doll Likeness
  • 四. webui 控件使用
    • prompt
    • sampler & step
  • 参考

文生图, 图生图 等 AIGC 创作大火, 也来体验一把~
本文记录了环境搭建过程与使用心得. 如果动手能力弱或只想省心, 有现成的整合包, 见参考[1]

环境要求

列出来我的环境吧:

  • CPU, AMD Ryzen 7 5800X 8-Core Processor
  • RAM, 32G
  • GPU, NVIDIA GeForce RTX 2070 SUPER (8G)
  • OS, Windows 11 专业版
  • 开发环境, python 3.10 与 git .

一. stable-diffusion-webui 安装

拉 git 仓库, git clone git@github.com:AUTOMATIC1111/stable-diffusion-webui.git 或直接下载 zip 文件.

windows/linux 安装

进入项目目录(stable-diffusion-webui), 运行 webui.bat (linux 为 webui.sh). 它会作很多搭建动作:

  1. 会创建 venv 虚拟环境, 安装 torch, numpy 等三方包, 位于 stable-diffusion-webui\venv\Lib\site-packages 中.

  2. 安装 github.com/TencentARC, github.com/openai/CLIP.git, github.com/mlfoundations/open_clip.git 等至 stable-diffusion-webui\venv\Lib\site-packages 中. 虽然也是 pip install , 但网络原因容易有报错:

     RuntimeError: Couldn't install gfpgan.
    Command: "D:\code_third_party\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 --prefer-binary
    stderr:   Running command git clone --filter=blob:none --quiet https://github.com/TencentARC/GFPGAN.git 'C:\Users\yichu\AppData\Local\Temp\pip-req-build-wo324g05'
      Running command git rev-parse -q --verify 'sha^8d2447a2d918f8eba5a4a01463fd48e45126a379'
      Running command git fetch -q https://github.com/TencentARC/GFPGAN.git 8d2447a2d918f8eba5a4a01463fd48e45126a379
      fatal: unable to access 'https://github.com/TencentARC/GFPGAN.git/': Failed to connect to github.com port 443 after 21054 ms: Couldn't connect to server
      error: subprocess-exited-with-error
    

    我的解决办法是, 把命令 git clone --filter=blob:none --quiet https://github.com/TencentARC/GFPGAN.git 'C:\Users\yichu\AppData\Local\Temp\pip-req-build-wo324g05' 复制出来, 将 https:// 子串改成 git@, 换成SSH通信, 然后单独执行. 再然后继续从头执行 webui.bat , 它会跳过已经就绪的步骤, 不用担心完全从头开始.

    tips: 要用ssh, 需要先登录 github 并把 SSH keys 添加到个人账户设置页中去.

  3. 拉取 [BLIP, CodeFormer, k-diffusion, stable-diffusion-stability-ai, taming-transformers] 几个 git 项目至stable-diffusion-webui\repositories\ 目录下. 注意这里不是 pip install, 而是直接拉仓库, 拉下来后各自目录下均有 .git 子目录. 见下:

docker 容器内安装

现在流行 docker, cli 中是 root 身份, 这时反而会报错 This script must not be launched as root, aborting..., 喵的, 使用 bash webui.sh -f 命令可以避开这个问题.

二. 运行 web-ui

上面的漫长安装是一次性的, 往后就可以快速(10s内)启动啦.
可以不再使用 webui.bat (webui.sh) , 仅用 python launch.py 即可.
常用参数:

  • --listen 指定 ip 是 ‘0.0.0.0’ 而不是 localhost 或 hostname, 适用 docker 容器内运行.
  • --enable-insecure-extension-access, 允许 web 中安装 扩展插件.

控制台输出见下:

> python launch.py --listen --enable-insecure-extension-access

Running on local URL:  http://0.0.0.0:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 8.5s (import torch: 2.0s, import gradio: 1.8s, import ldm: 0.5s, other imports: 1.7s, setup codeformer: 0.2s, load scripts: 1.0s, create ui: 0.8s, gradio launch: 0.4s).

自己打开浏览器, 填入相应 URL, 界面见下:

插件安装

civitai helper

additional network

不装也不影响 prompt 中自己叠加 lora 插件.

三. 常用模型

stable diffusion 模型

推荐使用参考[2] 的模型, 下载其 ckpt 资源, 约4GB.

chilloutmix

todo

LoRA 模型

Korean Doll Likeness

四. webui 控件使用

todo

prompt

sampler & step

参考

1.Bilibili 视频, 免部署整合包介绍
2. huggingface, stable-diffusion-v-1-4-original

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年12月7日
下一篇 2023年12月7日

相关推荐