AI绘画门槛又又又降低了,从最开始需要花半天时间折腾的 Disco-Diffusion ,紧接着 stable diffusion 在 github 上开源,各家平台都推出了云平台,让用户通过轻松的点击、选择、输入就能生成一张张AI图。
再到现在!!!使用 webui 在 github 上开源了,不仅有手动教程、docker 教程,还有 colab 傻瓜式的集成方案。
webui github 地址: https://github.com/sd-webui/stable-diffusion-webui
平台搭建
今天就来交大家如果来搭建和使用这个云平台。
第一步: 打开链接
https://colab.research.google.com/github/altryne/sd-webui-colab/blob/main/Stable_Diffusion_WebUi_Altryne.ipynb
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图1 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949797.webp-view)
第二步: 连接运行时
打开后,点击右上角的连接
。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图2 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949841.webp-view)
点击确定
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图3 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949508.webp-view)
等连接上后我们运行第一段脚本,就是查看当前使用的机器。一般是从 K80、T4、P100、V100 中随机分配一个。
第三步: 设置 Token
点击这个 1 – Setup stage 左边的小箭头进行展开
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图4 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949592.webp-view)
划到 1.4 Connect to Google Drive
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图5 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949301.webp-view)
勾选 download_if_missing ,然后到 https://huggingface.co/settings/tokens 复制你的 toekn 并填入,关于 huggingface 如何注册,可以看我上一篇文章《程序员秋风:AI数字绘画 stable-diffusion 保姆级教程》
重要的一步!!!!
打开 CompVis/stable-diffusion-v1-4 · Hugging Face , 点击 Access repository
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图6 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949162.webp-view)
第四步: 设置密码
划到 2 – Run the Stable Diffusion webui 部分,因为要部署一个服务,当然得设置一个密码,不然人人都可以随意使用你的服务了。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图7 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949618.webp-view)
第五步:运行服务
将他们收起来,依次运行以下步骤
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图8 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949538.webp-view)
第六步: 打开 Web 服务
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图9 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949716.webp-view)
账号为 webui,密码如果设置了就是你设置的密码。
使用教程
打开后就是这样一个界面,主要包含了4块功能,text2img,img2img,人脸修复算法,照片清晰化。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图10 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949361.webp-view)
text2img
我们首先来看 text2img,也就是输入一段文字就可以生成一张照片。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图11 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171949734.webp-view)
然后来看生成的一些案例吧
prompt: a girl with lavender hair and black skirt, fairy tale style background, a beautiful half body illustration, top lighting, perfect shadow, soft painting, reduce saturation, leaning towards watercolor, art by hidari and krenz cushart and wenjun lin and akihiko yoshida
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图12 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950200.webp-view)
rimuru looking into the camera, beautiful face, ultra realistic, fully clothed, intricate details, highly detailed, 8 k, photorealistic, octane render, unreal engine, photorealistic, portrait
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图13 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950423.webp-view)
((a point coloration cat by the lakeside)), big face, small ears, play in the snow, sharp focus, illustration, highly detailed, concept art, matte, anime, trending on artstation
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图14 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950520.webp-view)
prompt: Cyberpunk, 8k resolution, castle, the rose sea, dream
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图15 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950793.webp-view)
水墨画风格
prompt: a watercolor ink painting of a fallen angel with a broken halo wielding a jagged broken blade standing on top of a skyscraper in the style of anti – art trending on artstation deviantart pinterest detailed realistic hd 8 k high resolution
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图16 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950265.webp-view)
img2img
这个功能则是利用图片生成图片的功能。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图17 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950947.webp-view)
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图18 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950945.webp-view)
这里需要注意的是,不知道是不是我电脑的分辨率问题,默认宽高为 512 和 256,这个时候会报以下错误,但是将宽度调整成 1024 * 512 就没有问题
RuntimeError: The size of tensor a (128) must match the size of tensor b (32) at non-singleton dimension 3
生成的一些案例:
A fantasy landscape, trending on artstation
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图19 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](http://oss.xueai.net/2023/05/20230514171950564.webp-view)
A fantasy landscape, trending on artstation
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图20 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/ysgssmggxh2.webp-view)
a nike sneakers
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图21 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/1dl0ebdw315.webp-view)
人像优化
直接将老照片拖入框框。
案例:
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图22 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/msfhdsfdalx.webp-view)
清晰度优化
如果你觉得你生成的图片质量不够,可以使用这个功能进行4倍图进行放大。这个功能生成时间比较久,需要耐心等待, 大约5-10分钟,最终生成的清晰度提升还是蛮大的。
案例:
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图23 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/f4b1qcdbzv4.webp-view)
最后附上一个常见参数说明
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图24 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/rp50hsbvtra.webp-view)
更多内容请查看我整理的 Github https://github.com/hua1995116/awesome-ai-painting, 包含了 30+个 AI 绘画平台,SD 和 DD 使用教程,调参教程以及其他的文档。
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图25 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/vhfyq0uuvoo.webp-view)
问题汇总:
1.ImportError: this version of pandas is incompatible with numpy < 1.20.3
your numpy version is 1.19.2.
Please upgrade numpy to >= 1.20.3 to use this pandas version
解决方案:新建一个代码块输入
!pip install numpy== 1.20.3
2.[Errno 2] No such file or directory: ‘/content/drive/MyDrive/AI/models/sd-v1-4.ckpt’
解决方案:
仔细阅读中间部分,需要点开链接统一一个协议,你才有权限拉取模型
![用Colab免费部署自己的AI绘画云平台—— Stable Diffusion插图26 用Colab免费部署自己的AI绘画云平台—— Stable Diffusion](05/13/xhhfussx3mq.webp-view)