AI 绘画工具 Stable Diffusion 本地安装使用教程

2023-06-2709:15:58办公软件与工具应用Comments2,201 views字数 4944阅读模式

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

最近要用到 AI 绘画,所以研究了下目前市面上的 AI 绘画工具,真可谓是琳琅满目,但主流的还是 Stable diffusion 和 Midjourney 两大阵营。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

Midjourney 不多说,开箱即用,对新手非常友好,但不免费,Stable diffusion 相对 Midjourney 来说,专业性更强,不易上手,但更灵活,指哪打哪,模型生态丰富,最重要的是免费!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

树先生总结了目前使用 Stable diffusion 的几种不同姿势,还没上车的朋友们快跟着我一起上车吧~文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

SD 镜像网站

推荐指数:★☆☆☆☆文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

适用人群:浅尝辄止地体验玩家文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

如果你只想浅尝辄止地体验一下 AI 绘画的魅力,可以考虑使用一些 SD 的在线网站,比如 DreamStudio,可免费生成 200 张图片,之后需要缴费,这类在线网站对生成的图片的调教功能偏弱,无法批量生成图片,体验着玩玩还行,不适合深度玩耍。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

云服务器

推荐指数:★★★★☆文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

适用人群:本地电脑无法运行 Stable diffusion 的玩家文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

如果你本地电脑不满足安装 Stable diffusion 的条件,可以考虑使用云服务器,现在很多云服务器厂商都自带了 Stable diffusion 的镜像,一键启动,非常方便,就是需要一些费用~文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

准备工作

这里我们还是白嫖阿里云的机器学习 PAI 平台,使用 A10 显卡,这部分内容之前文章中有介绍。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

【注意】:镜像选择选择官方镜像中的 stable-diffusion-webui-env:pytorch1.13-gpu-py310-cu117-ubuntu22.04文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

项目部署

环境准备好了以后,就可以开始部署工作了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

【说明】:由于Github访问存在不稳定性,如果运行后未出现正常返回结果且提示网络相关原因,例如:Network is unreachableunable to access '``https://github.com/......',您可以重新运行命令。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

下载源码文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
git checkout a9fed7c364061ae6efb37f797b6b522cb3cf7aa2
mkdir -p repositories && cd repositories
git clone https://github.com/sczhou/CodeFormer.git

下载常用插件文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

cd stable-diffusion-webui/extensions
git clone https://gitcode.net/mirrors/DominikDoom/a1111-sd-webui-tagcomplete.git
git clone https://gitcode.net/ranting8323/stable-diffusion-webui-localization-zh_CN
cd ..
wget -c http://pai-vision-data-sh.oss-cn-shanghai.aliyuncs.com/aigc-data/webui_config/config.json

下载 chilloutmix 大模型文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

cd stable-diffusion-webui/models/Stable-diffusion
wget -c https://huggingface.co/naonovn/chilloutmix_NiPrunedFp32Fix/resolve/main/chilloutmix_NiPrunedFp32Fix.safetensors -O chilloutmix_NiPrunedFp32Fix.safetensors

下载额外模型文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

cd stable-diffusion-webui/repositories/CodeFormer/weights/facelib
wget -c http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/datasets/try_on/detection_Resnet50_Final.pth
wget -c http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/datasets/try_on/parsing_parsenet.pth

mkdir -p stable-diffusion-webui/models/Codeformer
cd stable-diffusion-webui/models/Codeformer 
wget -c http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/datasets/try_on/codeformer-v0.1.0.pth

cd stable-diffusion-webui/embeddings 
wget -c http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/datasets/try_on/ng_deepnegative_v1_75t.pt

cd stable-diffusion-webui/models/Lora
wget -c https://huggingface.co/Kanbara/doll-likeness-series/resolve/main/koreanDollLikeness_v10.safetensors

启动服务文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

cd stable-diffusion-webui
python -m venv --system-site-packages --symlinks venv
sed -i 's/can_run_as_root=0/can_run_as_root=1/g' webui.sh
./webui.sh --no-download-sd-model --xformers

服务启动成功后,左键点击生成的 URL 即可跳转到 WebUI 前端。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

生成第一张图片

# prompt
<lora:koreanDollLikeness_v10:1> 
the best quality, ultra-high definition,masterpiece, extreme detail, 8K
1girl, curly hair, detail eyes and mouth, fair skin,big eyes,
white shirt, 
street
 
# negative prompt 
(worst quality:2), (low quality:2), (normal quality:2), lowres, ((monochrome)), ((grayscale)), bad anatomy,DeepNegative, skin spots, acnes, skin blemishes,(fat:1.2),facing away, looking away,tilted head, lowres,bad anatomy,bad hands, missing fingers,extra digit, fewer digits,bad feet,poorly drawn hands,poorly drawn face,mutation,deformed,extra fingers,extra limbs,extra arms,extra legs,malformed limbs,fused fingers,too many fingers,long neck,cross-eyed,mutated hands,polar lowres,bad body,bad proportions,gross proportions,missing arms,missing legs,extra digit, extra arms, extra leg, extra foot,teethcroppe,signature, watermark, username,blurry,cropped,jpeg artifacts,text,error,

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

泰裤辣!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

本地安装

推荐指数:★★★★★文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

适用人群:本地电脑可以运行 Stable diffusion 的玩家文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

安装环境

要在本地顺利运行 Stable diffusion,需要满足如下条件:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

  • 操作系统 win10 以上
  • 内存 8GB 以上
  • GPU 必须是 N 卡,显存 4GB 以上

以上是最基本的硬件配置。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

安装 Python文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

Python 版本需要 3.10.6,Python 安装可以参考我之前写的这篇。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

安装 CUDA文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

接下来安装 CUDA,CUDA是 Nvidia 显卡的 AI 运算库,Stable diffusion 通过这个库使用显卡资源。命令行输入nvidia-smi,查看自己显卡支持的版本。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

然后去 Nvidia CUDA 官网下载支持的版本。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

项目部署

下载源码文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

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

一键启动文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

这里使用 B 站秋葉的启动器,支持一键启动/修复/更新/模型下载管理,后台回复【qiuye】获取。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

运行启动器运行依赖安装依赖包,解压sd-webui启动器.zip,将解压后的文件复制到项目源代码目录下,最后运行A启动器启动项目。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

点击一键启动,耐心等待一段时间,直到看到下图代表启动成功。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

下载模型

细心的朋友会发现上图有报错,说是没找到 checkpoints,其实就是没有对应的大模型,我们回到秋葉的启动器,在模型管理中下载自己喜欢的大模型即可,也可以去 Civitai 网站下载。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

耐心等待下载完成。。。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

刷新浏览器访问 http://127.0.0.1:7860 即可看到熟悉的界面。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

汉化

依次点击 Extensions --> Available --> Load from加载插件列表,在搜索框输入cn搜索语言包,点击安装文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

下载完成后,选择 setting --> user interface --> localization,选择 zh_CN,点击 Apply settings 按钮应用设置,再点击 Reload UI 刷新页面。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

汉化成功~文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

生成第一张图片

# prompt
the best quality, ultra-high definition,masterpiece, extreme detail, 8K
1girl, curly hair, detail eyes and mouth, fair skin,big eyes,
white shirt, 
street
 
# negative prompt 
(worst quality:2), (low quality:2), (normal quality:2), lowres, ((monochrome)), ((grayscale)), bad anatomy,DeepNegative, skin spots, acnes, skin blemishes,(fat:1.2),facing away, looking away,tilted head, lowres,bad anatomy,bad hands, missing fingers,extra digit, fewer digits,bad feet,poorly drawn hands,poorly drawn face,mutation,deformed,extra fingers,extra limbs,extra arms,extra legs,malformed limbs,fused fingers,too many fingers,long neck,cross-eyed,mutated hands,polar lowres,bad body,bad proportions,gross proportions,missing arms,missing legs,extra digit, extra arms, extra leg, extra foot,teethcroppe,signature, watermark, username,blurry,cropped,jpeg artifacts,text,error,

AI 绘画工具 Stable Diffusion 本地安装使用教程文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/office/48527.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/office/48527.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定