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

news/2024/7/10 20:09:04 标签: AIGC, stable diffusion

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

<a class=AIGC" />

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

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

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

网页版本:

  • 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.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://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-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

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.niftyadmin.cn/n/1490165.html

相关文章

Mysql性能优化学习笔记

MySQL性能优化原理与笔记: 1.MySQL会为每个线程分配一个内存&#xff08;sort_buffer&#xff09;用于排序该内存大小为sort_buffer_size 1>如果排序的数据量小于sort_buffer_size&#xff0c;排序将会在内存中完成 2>如果排序数据量很大&#xff0c;内存中无法存下这…

记一次MySQL语句执行问题

表结构如下&#xff1a; mysql> CREATE TABLE table_a (id int(11) NOT NULL,b varchar(10) DEFAULT NULL,PRIMARY KEY (id),KEY b (b) ) ENGINEInnoDB; 假设现在表里面&#xff0c;有 100 万行数据&#xff0c;其中有 10 万行数据的 b 的值是’1234567890’&#xff0c; 假…

Java中位运算详解

最近在做题时候&#xff0c;经常遇到位运算&#xff0c;这里对java中的位运算i做一个总结&#xff0c;以便复习。 一、什么是位运算&#xff1f;使用位运算有什么好处&#xff1f; 1、什么是位运算&#xff1f; 计算机在底层使用的是二进制补码进行运算。对应的二进制位进行操作…

MySQL高级优化之到底可不可以使用join?

在实际生产中&#xff0c;关于 join 语句使用的问题&#xff0c;一般会集中在以下两类&#xff1a; 我们 DBA 不让使用 join&#xff0c;使用 join 有什么问题呢&#xff1f;如果有两个大小不同的表做 join&#xff0c;应该用哪个表做驱动表呢&#xff1f; 今天这篇文章&#…

获取网页信息并处理

package mainimport ("encoding/json""fmt""io/ioutil""net/http" )type Node struct{//属性 }func main(){//获取浏览器resp,err:http.Get("http://www.tianqiapi.com/api?versionv9&appid23035354&appsecret8YvlPNrz&…

重新排序

1、题目 2、解题1 申请空间解法 package main import . "nc_tools" /** type ListNode struct{* Val int* Next *ListNode* }*//*** * param head ListNode类 * return void */ func reorderList( head *ListNode ) {// write code hereif head nil{return}v…

两个链表生成相加链表

1、题目 假设链表中每一个节点的值都在 0 - 9 之间&#xff0c;那么链表整体就可以代表一个整数。 给定两个这种链表&#xff0c;请生成代表两个整数相加值的结果链表。 例如&#xff1a;链表 1 为 9->3->7&#xff0c;链表 2 为 6->3&#xff0c;最后生成新的结果链…