侧边栏壁纸
博主头像
Kefei的记事本博主等级

好脑瓜不如烂笔头

  • 累计撰写 219 篇文章
  • 累计创建 11 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录
AI

Stable Diffusion本地部署

Administrator
2024-06-08 / 0 评论 / 0 点赞 / 0 阅读 / 1396 字

Stable Diffusion是一个开源的图像生成AI模型,可以部署在本地运行。部署步骤如下:

1. 准备环境:

- Python 3.6+

- CUDA 11.1+

- CuDNN 8.0+

- NVIDIA GPU (推荐RTX 2060或以上)

2. 安装依赖:

bash

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

pip install omegaconf pytorch-lightning endothelin einops

3. 下载模型权重:

models.py已经内置了Carl Roux版的Stable Diffusion权重,你可以在 [这里](https://github.com/CompVis/stable-diffusion) 找到并下载其他权重。

4. 下载脚本代码:

bash

git clone https://github.com/CompVis/stable-diffusion.git

cd stable-diffusion

5. 生成图片:

bash

python scripts/generate.py --prompt "A scenic view of mountains near a lake"

generate.py脚本支持多种参数来生成不同风格的图片,具体可以参考仓库自带的文档。

6. 启动Web UI (可选):

如果想通过Web页面生成图片,可以启动stable-diffusion-webui:

bash

git clone https://github.com/yzubin/stable-diffusion-webui.git

cd stable-diffusion-webui

python app.py

然后在浏览器中访问 http://localhost:7860 即可使用Web UI生成图片。

以上步骤可以在本地成功部署并运行Stable Diffusion模型。如果在部署过程中遇到问题,可以参考仓库中的issues讨论,或在相关论坛搜索解决方案。

0

评论区