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

news/2024/10/17 23:23:44/

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

AIGC

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

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

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

运行 WebUI 环境 :

source venv/bin/activate
python launch.py --port 9301 --listen --xformers
nohup python -u launch.py --port 9301 --listen --xformers > nohup.sd.out &

网页版本:

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

1. 环境配置

下载工程:

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

自动配置环境:

cd stable-diffusion-webui
python3 webui.py  # 自动安装环境

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

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

遇到问题,在虚拟环境中,手动安装一些包,注意解决 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.16pip 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://github.com/mlfoundations/open_clip.git --prefer-binary

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

git clone git@github.com:CompVis/taming-transformers.git

运行 WebUI 环境 :

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

启动成功:

UI

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 /nfs/chenlong/stable_diffusion/stable-diffusion-webui/model.ckpt- directory /nfs/chenlong/stable_diffusion/stable-diffusion-webui/models/Stable-diffusionCan'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

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

Config

近景Prompts

look at viewer,close up,upper body

参考:

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

http://www.ppmy.cn/news/733574.html

相关文章

ubuntu使用命令将cpu锁频

#上限sudo cpufreq-set -c i -u 3.8GHz # i 是你的线程id 比如你是4核心4线程,那么i{0,1,2,3} #下限 sudo cpufreq-set -c i -d 3.8GHz#安装 sudo apt-get install cpufrequtils#cpu信息查看 cpufreq-info

RK3399 CPU锁频

1、关闭CPU温控,否则系统还是会自动降频 echo disabled > /sys/class/thermal/thermal_zone0/mode echo 0 > /sys/class/thermal/thermal_zone0/cdev0/cur_state echo 0 > /sys/class/thermal/thermal_zone0/cdev1/cur_state echo 0 > /sys/class/ther…

linux线程阻塞中CPU的占用率

linux线程阻塞中CPU的占用率 一、简介 总所周知Linux系统下,我们编写的程序进入阻塞后,系统把任务挂起,交给内核进行处理,此时我们的进程CPU占用率不高,可以说是占用率0.0%,让CPU资源交给其他进程处理&am…

j4125锁频,ESXI无睿频原因及解决方法(修改BIOS设置)

声明:本教程仅供学习参考,因对BIOS的操作带来的风险自行承担 我的设备是畅网J4125 i226网卡版本,装了ESXI8.0,装好后ESXI只识别基频2.0GHz,四核共7.99GHz,跑满CPU频率能达到8.6GHz,无法达到睿频…

CPU的睿频、超线程、SIMD指令集等特性对密码算法性能的影响

摘要:本文档以XX密码算法为例,研究对CPU的睿频、超线程、SIMD指令集等特性对密码算法性能的影响。初步结结论为:1)睿频很重要,默认是开启的,尽量不要关闭,注意全核睿频通常小于最大睿频&#xf…

linux(五)——TX1的cpu/gpu锁频(设置最大频率)

一、背景介绍 主频:CPU自己运算的频率 外频:CPU和外部设备协作的频率 倍频:主频/外频 超频:升高主频,提高运算效率 锁频:一般是为了防止超频,把倍频锁定在特定数字 二、频率的修改 这里以…

MacBook笔记本安装win10后cpu被锁频,无法以满速运行的解决办法

最近把自己的老款08年的MacBook安装了win10,进系统发现本来2.0Ghz的cpu却一直运行在1.5Ghz下,由于MacBook不像普通Windows笔记本可以进BIOS调节参数,只能在安装的系统上想办法,用以下三板斧可以让cpu满速运行 1 在Power Options中…

对Android设备CPU进行锁频

本文对Android设备CPU的状态查看方法和锁频(lock frequency)方法进行详细介绍。这有什么用?作为测试工程师,你值得了解。 CPU频率 首先说下CPU的频率。我们都知道,CPU的工作频率越高,运算就越快,但能耗也更高。然而很多时候&…