Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置

这篇具有很好参考价值的文章主要介绍了Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

欢迎关注我的CSDN:https://spike.blog.csdn.net/
本文地址:https://spike.blog.csdn.net/article/details/131528224

Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置,大模型(LLM&AIGC),AIGC,stable diffusion

Stable Diffusion WebUI 是一款基于深度学习的图像生成工具,根据用户的输入文本或图像,生成高质量的新图像,特点如下:

  • 支持多种图像生成任务,如人脸生成、风格迁移、图像修复、图像超分辨率等。
  • 使用稳定扩散模型(Stable Diffusion Model)作为图像生成的核心算法,该模型具有高效、稳定、可控的优势。
  • 提供友好的 Web 界面,用户可以通过浏览器访问和使用,无需安装任何软件或插件。
  • 支持自定义参数和模型,用户可以根据自己的需求和喜好,调整图像生成的效果和风格。

Stable Diffusion WebUI 是一款适合各类用户的图像生成工具,无论你是专业的设计师、艺术家、摄影师,还是普通的爱好者、学习者,都可以在这里发挥你的创意和想象力,生成你想要的图像。

运行 WebUI 环境 :

source venv/bin/activate

python -u launch.py --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue

nohup python -u launch.py --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue > nohup.62.out &

网页版本:

  • GitHub:https://github.com/AUTOMATIC1111/stable-diffusion-webui
  • 安装文档:https://stable-diffusion-book.vercel.app/install/WebUi/launch/

1. 环境配置

下载工程(工程文件约 23118 个,下载速度较慢):

git clone git@github.com:AUTOMATIC1111/stable-diffusion-webui.git

自动配置环境(需要安装的 Python 环境较多,下载速度较慢):

cd stable-diffusion-webui
bash webui.sh  # 自动安装环境

日志如下:

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on [your name] user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

默认配置的 Python 环境位于: stable-diffusion-webui/venv/bin/activate,即使用虚拟环境 virtualenv,即:

conda deactivate   # 取消 conda
source venv/bin/activate  # 激活

遇到 PyTorch GPU 错误,重新安装 PyTorch 即可。

遇到问题,在虚拟环境中,手动安装一些包,注意解决 Python 包的版本冲突:

pip install einops==0.3.0 kornia==0.6 omegaconf==2.1.1 pytorch-lightning==1.4.2 torchmetrics==0.6.0 transformers==4.26.1 torch==2.0.1 torchvision==0.15.2 google-auth==2.22.0rc1 urllib3==1.26.16

pip install facexlib==0.3.0 tb-nightly==2.14.0a20230702 sdkit==1.0.112 opencv-python==4.6.0.66 -i https://mirrors.aliyun.com/pypi/simple

# 需要安装
# pip install git+https://ghproxy.com/https://github.com/mlfoundations/open_clip.git --prefer-binary
pip install open-clip-torch==2.0.2 deepspeed==0.9.5
pip install opencv-python-headless==4.8.0.74 opencv-python==4.8.0.74

默认配置的工程环境位于:stable-diffusion-webui/repositories,手动下载依赖工程:

cd repositories/
git clone https://ghproxy.com/https://github.com/Stability-AI/stablediffusion.git stable-diffusion-stability-ai
git clone https://ghproxy.com/https://github.com/crowsonkb/k-diffusion.git/ k-diffusion
git clone https://ghproxy.com/https://github.com/sczhou/CodeFormer.git
git clone https://ghproxy.com/https://github.com/salesforce/BLIP.git
git clone https://ghproxy.com/https://github.com/CompVis/taming-transformers

最终 5 个文件夹:

BLIP/
CodeFormer/
k-diffusion/
stable-diffusion-stability-ai/
taming-transformers/

运行 WebUI 环境 :

conda deactivate
source venv/bin/activate
python launch.py --port 9301 --xformers

启动成功:

Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置,大模型(LLM&AIGC),AIGC,stable diffusion

Bug1: 遇到Bug “AttributeError: module ‘open_clip’ has no attribute ‘transformer’”

从源码安装open_clip,即可:

pip install git+https://github.com/mlfoundations/open_clip.git --prefer-binary

**Bug2: 遇到Bug “FileNotFoundError: No checkpoints found. When searching for checkpoints for Stable-diffusion” **

Stable-diffusion模型没有下载完成,即:

FileNotFoundError: No checkpoints found. When searching for checkpoints, looked at:
 - file stable_diffusion/stable-diffusion-webui/model.ckpt
 - directory stable_diffusion/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.

手动下载,大约4个G

cd models/Stable-diffusion
wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

Bug3: 遇到Bug “No module ‘xformers’. Proceeding without it.”

已经安装 xformers,不是Bug,因为没有启动命令参数所导致,launch.py 增加 --xformers 参数,即可:

python launch.py --port 9301 --listen --xformers

Bug4: 遇到Bug “Cannot locate TCMalloc”

缺少安装包 google-perftools,安装即可。

sudo apt install --no-install-recommends google-perftools

Bug5: 遇到 RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

原因是 PyTorch 安装异常,在 Python 中,调用 import torch 时,同样出现异常:
ImportError: cannot import name '_get_cpp_backtrace' from 'torch._C'

重新安装 PyTorch 即可,即先查看并卸载 PyTorch,再安装:

pip list | grep torch
pip uninstall torch torchvision
pip install torch==2.0.1 torchvision==0.15.2

测试命令,确保 PyTorch 运行正常:

import torch
print(torch.__version__)  # 2.0.1+cu117
import torchvision
print(torchvision.__version__)  # 0.15.2+cu117

也可使用,如下命令验证:

python -c "import torchvision; print(torchvision.__version__)"
python -c "import torch; print(torch.__version__)"

Bug6: 遇到 AttributeError: partially initialized module 'cv2' has no attribute '_registerMatType'

参考:AttributeError: partially initialized module ‘cv2’ has no attribute ‘_registerMatType’ (most likely due to a circular import)

pip install opencv-python-headless==4.8.0.74 opencv-python==4.8.0.74

2. 测试工程

第1块输入是正向Prompts,第2块输入是反向Prompts。

正向Prompts:

A girl,walking in the forest,the sun fell on her body,(masterpiece:1,2),best quality,masterpiece,highres,original,extremely detailed wallpaper,perfect lighting,(extremely detailed CG:1.2),drawing,paintbrush,

反向Prompts:

NSFW,(worst quality:2),(low quality:2),(normal quality:2),lowres,normal quality,((monochrome)),((grayscale)),skin spots,acnes,skin blemishes,age spot,(ugly:1.331),(duplicate:1.331),(morbid:1.21),(mutilated:1.21),(tranny:1.331),mutated hands,(poorly drawn hands:1.5),blurry,(bad anatomy:1.21),(bad proportions:1.331),extra limbs,(disfigured:1.331),(missing arms:1.331),(extra legs:1.331),(fused fingers:1.61051),(too many dingers:1.61051),(unclear eyes:1.331),lowers,bad hands,missing fingers,extra digit,bad hands,missing fingers,(((extra arms and legs)))

Restore faces(面部修复) 需要下载模型:

Downloading: "https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth" to stable-diffusion-webui/repositories/CodeFormer/weights/facelib/detection_Resnet50_Final.pth

# 下载失败,手动下载
cd repositories/CodeFormer/weights/facelib/
wget https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth

配置信息如下:Sampling method,Restore faces,CFG Scale

Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置,大模型(LLM&AIGC),AIGC,stable diffusion

近景Prompts

look at viewer,close up,upper body

参考:文章来源地址https://www.toymoban.com/news/detail-597248.html

  • GtiHub - StableDiffusionBook
  • stable-diffusion-webui的安装教程 ubuntu
  • Stable Diffusion - 安装过程中常见报错解决方法
  • GitHub - Xformers
  • GitHub - Bug: Cannot locate TCMalloc

到了这里,关于Stable Diffusion - Stable Diffusion WebUI 图像生成工具的环境配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • 本地生成动漫风格 AI 绘画 图像|Stable Diffusion WebUI 的安装和局域网部署教程

    先放一张WebUI的图片生成效果图,以给大家学习的动力 :) 怎么样,有没有小小的心动?这里再补充一下,是可以生成 NSWF 的图片的。 官方github项目 安装 python 3.10.6,记得将python添加到路径。 安装 git (非必要,可以直接从上面的github链接下载压缩文件) 下载 github 文件

    2024年02月01日
    浏览(50)
  • stable_diffusion_webui docker环境配置

    1.新建docker环境 2.安装miniconda 3.配置stable_diffusion_webui 直接使用stable_difffusion_webui下的launch.py可能会有些问题,建议 4.安装tensorrt 1.利用vim进入~/.bashrc文档,摁住ctrl+g,直接跳到最后一行,摁一下i键,进入插入模式,现在可以编辑文档了。 2.跳到最后一个字符,摁一下换行,可

    2024年02月12日
    浏览(25)
  • Windows下stable diffusion webui环境配置详细教程

    https://github.com/AUTOMATIC1111/stable-diffusion-webui 官方要求python版本3.10.6,实测python3.9.13可用 安装Python https://www.python.org/downloads/windows/ 2. 安装Git并配置 详情参考:https://blog.csdn.net/shuang_waiwai/article/details/121108964 3. Clone库stable-diffusion-webui 直接Git clone: 或: 4. 运行配置文件 强烈建议

    2024年02月11日
    浏览(41)
  • 闲谈【Stable-Diffusion WEBUI】的插件:模型工具箱:省空间利器

    本篇主要提到WEBUI的一个新插件,模型工具箱,可以修剪模型,提取修改模型组件信息。 更多不断丰富的内容参考:🔗 《继续Stable-Diffusion WEBUI方方面面研究(内容索引)》 参考:https://github.com/arenasys/stable-diffusion-webui-model-toolkit 可以从WEB UI中直接安装,它是一个用于管理、编

    2024年02月11日
    浏览(45)
  • Stable Diffusion - 配置 WebUI 升级至 v1.6.0 版本与 VirtualENV 环境配置

    欢迎关注我的CSDN:https://spike.blog.csdn.net/ 本文地址:https://spike.blog.csdn.net/article/details/132177882 图像基于 哥特风格 绘制,参考 哥特 (Goth) 风格服装与背景的 LoRA 配置 Stable Diffusion WebUI 是一款基于 Stable Diffusion 模型的网页前端工具,通过简单的文本输入或者图像修改来生成高质

    2024年02月08日
    浏览(33)
  • Stable Diffusion Online:AI图像生成工具

    【产品介绍】​ 名称              Stable Diffusion Online 成立时间​              Stable Diffusion的母公司Stability AI,成立于2020年。​ 具体描述        

    2024年01月24日
    浏览(37)
  • 《Stable Diffusion WebUI折腾实录》在Windows完成安装, 从社区下载热门模型,批量生成小姐姐图片

    操作系统: Windows11 显卡: RTX2060 6GB 显存 下载 Python3.10.6 安装 注意勾选 Add Python 3.10.6 to PATH ,然后一路 下一步 即可 打开powershell, 确认安装成功 下载git 完成安装 为了避免找不到开源项目,可以像上图中的我一样, 先在用户目录建立一个github文件夹,进入文件夹后,再下载开源

    2024年02月11日
    浏览(27)
  • AI作画工具 stable-diffusion-webui 本地部署 多种模型 可生成NSFW

    最近,人工智能绘画非常受欢迎。在本文中,我使用了一台带有N卡的电脑,安装了stable-diffusion-webui前端并替换了默认的模型。这样就可以生成高质量的二次元图像,并且可以不受限制地生成图片(在线版通常会阻止NSFW内容的生成)。 Git:https://git-scm.com/download CUDA:https://

    2024年02月02日
    浏览(66)
  • 使用Gradio搭建Stable Diffusion模型生成图像:简单快捷的图像生成体验

    目录 0 开发环境 1 介绍 1.1 Gradio简介 1.2 Stable Diffusion模型简介 2 使用Gradio搭建基本界面 2.1 安装依赖库 2.2 加载预训练模型 2.3 解析返回的数据 2.4 构建图像字幕应用程序 3 实现Stable Diffusion图像生成 3.1 Stable Diffusion模型解析 3.2 将SD模型集成到Gradio应用中 3.2.1 本地加载 3.2.1.1 安

    2024年02月13日
    浏览(35)
  • 扩散模型实战(十):Stable Diffusion文本条件生成图像大模型

     扩散模型实战(一):基本原理介绍 扩散模型实战(二):扩散模型的发展 扩散模型实战(三):扩散模型的应用 扩散模型实战(四):从零构建扩散模型 扩散模型实战(五):采样过程 扩散模型实战(六):Diffusers DDPM初探 扩散模型实战(七):Diffusers蝴蝶图像生成实

    2024年02月03日
    浏览(42)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包