Stable Diffusion是一个文本到图像的潜在扩散模型,由CompVis、Stability AI和LAION的研究人员和工程师创建。它使用来自LAION-5B数据库子集的512x512图像进行训练。使用这个模型,可以生成包括人脸在内的任何图像,因为有开源的预训练模型,所以我们也可以在自己的机器上运行它。
一、本地安装
Tip: Python 版本为 3.10.6
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui/
# 请切换Python venv, 魔法上网, 下载时间比较长
git config --global http.proxy http://127.0.0.1:10887
pip install --upgrade pip
export http_proxy=http://127.0.0.1:10887;export https_proxy=http://127.0.0.1:10887;
sh ./webui.sh
二、安装报错汇总
2.1 安装gfpgan报错
Installing gfpgan
Traceback (most recent call last):
File "/Users/iarno/Devspace/chatgpt/stable-diffusion-webui/launch.py", line 355, in <module>
prepare_environment()
File "/Users/iarno/Devspace/chatgpt/stable-diffusion-webui/launch.py", line 263, in prepare_environment
run_pip(f"install {gfpgan_package}", "gfpgan")
File "/Users/iarno/Devspace/chatgpt/stable-diffusion-webui/launch.py", line 129, in run_pip
return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
File "/Users/iarno/Devspace/chatgpt/stable-diffusion-webui/launch.py", line 97, in run
raise RuntimeError(message)
RuntimeError: Couldn't install gfpgan.
Command: "/Users/iarno/Devspace/chatgpt/stable-diffusion-webui/venv/bin/python3.10" -m pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 --prefer-binary
Error code: 2
stdout: Collecting git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
Cloning https://github.com/TencentARC/GFPGAN.git (to revision 8d2447a2d918f8eba5a4a01463fd48e45126a379) to /private/var/folders/qw/4fkzpn79447fkgjgk19pq_6h0000gn/T/pip-req-build-0i1rio01
stderr: Running command git clone --filter=blob:none --quiet https://github.com/TencentARC/GFPGAN.git /private/var/folders/qw/4fkzpn79447fkgjgk19pq_6h0000gn/T/pip-req-build-0i1rio01
Running command git rev-parse -q --verify 'sha^8d2447a2d918f8eba5a4a01463fd48e45126a379'
Running command git fetch -q https://github.com/TencentARC/GFPGAN.git 8d2447a2d918f8eba5a4a01463fd48e45126a379
Running command git checkout -q 8d2447a2d918f8eba5a4a01463fd48e45126a379
解决方案:
git config --global http.proxy http://127.0.0.1:10887
2.2 未下载模型导致服务无法运行
No checkpoints found. When searching for checkpoints, looked at:
- file /Users/liuli/Devspace/chatgpt/stable-diffusion-webui/model.ckpt
- directory /Users/liuli/Devspace/chatgpt/stable-diffusion-webui/models/Stable-diffusion
Can't run without a checkpoint. Find and place a .ckpt or .safetensors file into any of those locations. The program will exit.
解决方案:
下载模型, 并将下载的模型放到 stable-diffusion-webui/models/Stable-diffusion
目录中。
三、使用Colab搭建
Colab 免费时长为12小时
本地模型生成图片会受限于💻配置问题, 推荐使用谷歌免费 Colab
服务搭建, 避免多次下载 Model
模型, 可以考虑使用挂载谷歌云盘的方式(提前将下载好的Model上传至谷歌云盘)。
3.1 安装教程:
3.2 修改项
挂载云盘:
拷贝云盘模型:
四、参考
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
https://github.com/camenduru/stable-diffusion-webui-colab.git
https://www.bilibili.com/video/BV1vX4y1k7d4?vd_source=59a19d02212b7e9ac600f7c97d180b9d
https://www.bilibili.com/video/BV1fL411U77A?vd_source=59a19d02212b7e9ac600f7c97d180b9d