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

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

    正在检查是否收录...

最近要用到 AI 绘画,所以研究了下目前市面上的 AI 绘画工具,真可谓是琳琅满目,但主流的还是 Stable diffusion 和 Midjourney 两大阵营。

Midjourney 不多说,开箱即用,对新手非常友好,但不免费,Stable diffusion 相对 Midjourney 来说,专业性更强,不易上手,但更灵活,指哪打哪,模型生态丰富,最重要的是免费!

树先生总结了目前使用 Stable diffusion 的几种不同姿势,还没上车的朋友们快跟着我一起上车吧~

SD 镜像网站

推荐指数:★☆☆☆☆

适用人群:浅尝辄止地体验玩家

如果你只想浅尝辄止地体验一下 AI 绘画的魅力,可以考虑使用一些 SD 的在线网站,比如 DreamStudio,可免费生成 200 张图片,之后需要缴费,这类在线网站对生成的图片的调教功能偏弱,无法批量生成图片,体验着玩玩还行,不适合深度玩耍。

云服务器

推荐指数:★★★★☆

适用人群:本地电脑无法运行 Stable diffusion 的玩家

如果你本地电脑不满足安装 Stable diffusion 的条件,可以考虑使用云服务器,现在很多云服务器厂商都自带了 Stable diffusion 的镜像,一键启动,非常方便,就是需要一些费用~

准备工作

这里我们还是白嫖阿里云的机器学习 PAI 平台,使用 A10 显卡,这部分内容之前文章中有介绍。

免费部署一个开源大模型 MOSS

【注意】:镜像选择选择官方镜像中的 stable-diffusion-webui-env:pytorch1.13-gpu-py310-cu117-ubuntu22.04

项目部署

环境准备好了以后,就可以开始部署工作了。

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

下载源码

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 

下载常用插件

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 大模型

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

下载额外模型

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 

启动服务

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 前端。

生成第一张图片

# 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, 

泰裤辣!

本地安装

推荐指数:★★★★★

适用人群:本地电脑可以运行 Stable diffusion 的玩家

安装环境

要在本地顺利运行 Stable diffusion,需要满足如下条件:

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

以上是最基本的硬件配置。

安装 Python

Python 版本需要 3.10.6,Python 安装可以参考我之前写的这篇。

【保姆级】Python最新版开发环境搭建,看这一篇就够了

安装 CUDA

接下来安装 CUDA,CUDA是 Nvidia 显卡的 AI 运算库,Stable diffusion 通过这个库使用显卡资源。命令行输入nvidia-smi,查看自己显卡支持的版本。

然后去 Nvidia CUDA 官网下载支持的版本。

项目部署

下载源码

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

一键启动

这里使用 B 站秋葉的启动器,支持一键启动/修复/更新/模型下载管理,后台回复【qiuye】获取。

运行启动器运行依赖安装依赖包,解压sd-webui启动器.zip,将解压后的文件复制到项目源代码目录下,最后运行A启动器启动项目。

点击一键启动,耐心等待一段时间,直到看到下图代表启动成功。

下载模型

细心的朋友会发现上图有报错,说是没找到 checkpoints,其实就是没有对应的大模型,我们回到秋葉的启动器,在模型管理中下载自己喜欢的大模型即可,也可以去 Civitai 网站下载。

耐心等待下载完成。。。

刷新浏览器访问 http://127.0.0.1:7860 即可看到熟悉的界面。

汉化

依次点击 Extensions --> Available --> Load from加载插件列表,在搜索框输入cn搜索语言包,点击安装

下载完成后,选择 setting --> user interface --> localization,选择 zh_CN,点击 Apply settings 按钮应用设置,再点击 Reload UI 刷新页面。

汉化成功~

生成第一张图片

# 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, 

好了,就到这里,Stable diffusion 的玩法很多,这里只是最基本的文生图功能,就已经很强大了,其他的就交给你们自己去探索吧。

codediffusiongitwebwebuistable diffusionclonegithubpython大模型urlutmpromptmidjourney云服务器服务器fix云服务ai 绘画gpuchromeerpdefihuggingfaceparse批量生成文生图dream绘画工具易上手机器学习jsonelo开源大模型stem浏览器命令行pytorch操作系统aigc模型管理稳定性免费素材
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-2902.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

使用Stable Diffusion进行Ai+艺术设计(以智慧灯杆为例)

上一篇

分享一个可以同时免费使用ChatGPT和Bard的网站

下一篇
  • 复制图片
按住ctrl可打开默认菜单