AI画画工具 Stable Diffusion 指北

Generative AI curated by @aaronsiim

去年突然冒出了一大堆的AI工具,先是各种画画的工具,再然后就是火爆的ChatGPT.

以前也有各种工具,如:AlphaGo, AI修复视频、图片,AI换脸,都是某些个领域的辅助技术或者决策工具,现在新冒出的AI技术应用范围到了从无生到有生成一个新的东西出来,这就有点神奇了。

我已经被 ChatGPT 惊住了。

你很难相信他不明白

但是这些新的AI工具不提训练模型的过程,就是使用这些工具对于个人用户的硬件条件都是达不到要求的,大多是都是提供网络服务调用API啥的。但是 Stable Diffusion 就让AI画画工具不仅能够在个人用户计算机上跑,对于显卡的要求也大大降低了,遂想尝试一下这个AI画画,看看他到底有什么能耐。

下面的内容并不是教程,主要是记录一下找到的资料,及自己的尝试,已经一些在尝试的过程中遇到的问题及解决办法。

看了好多教程,教程各不相同,主要是是 Stable Diffusion 有很多 fork 版本,也有加强功能不叫这个名字的版本。

各种版本及教程

  1. CompVis/stable-diffusion

    这个是原版的stable diffusion,按照这个部署对于有8G显存的显卡只能生成 256*256 像素大小的图片。如果想生成更大图片需要使用修改版的 stable diffusion

    这个修改版我是从这个教程中看到的:AI 绘画 Stable Diffusion V1 本地 Windows 零基础搭建

    可以将优化版的 repo 下载下来后,将其中的optimizedSD文件夹拷贝到原版的文件夹下使用。具体步骤可参考上面的教程。

    有两种使用功能,一种是根据文字生成图片,还有一种是根据提供的图片加上文字生成图片。

    分别的使用方式命令如下:

    文字转图片:

    python optimizedSD/optimized_txt2img.py --prompt "A cyberpunk city with a spaceship in the sky" --H 512 --W 512 --seed 27 --n_iter 2 --n_samples 5 --ddim_steps 50

    图片转文字:

    python optimizedSD/optimized_img2img.py --prompt "A cyberpunk city with a spaceship in the sky" --init-img ..\init_img\input.jpg --strength 0.8 --n_iter 2 --n_samples 5 --H 512 --W 512

    命令参数具体作用查看此处

    还有一个涂抹图片然后用AI填充的功能,我还没有试过。

    可能出现的问题

    • 下载中断

      在部署的时候很可能因为网络的问题卡在下载”“https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth”这个文件的地方,可以手动下载文件后,将此文件放到%USERPROFILE%\.cache\torch\hub\checkpoints目录下即可。

    • requests.exceptions.ProxyError 网络设置代理问题

      如果你在windows系统设置中设置了https代理,会与此版本的 python urllib 发生冲突,这是一个 bug,具体参考此处:requests/issues/5740,issue42627

  2. AUTOMATIC1111/stable-diffusion-webui

    其实这个官方wiki就写的很清楚了。https://github.com/AUTOMATIC1111/stable-diffusion-webui#installation-and-running

    1. Required Dependencies
    2. Install and Run on NVidia GPUs

    遇到git下载问题,需要科学上网。使用下面的命令给git设置访问github时使用代理。

    git config --global http.https://github.com.proxy socks5h://127.0.0.1:[your proxy port]

  3. invoke-ai/InvokeAI

  4. huggingface/diffusers

目前的 stable diffusion AI 画画效果一般,没有达到预期水平。DALL·E 2 效果更好,Midjourney 也还没有尝试。

选几张看看效果:

Chinese_paper-cut_art_of_sunwukong

Year of the Rabbit

The_mountains end with the plain, the river flows into the wilderness,chinese style

massive iron golem guarding an ancient temple, epic fantasy art, highly detailed and intricate, underground, depth of view

a crying stone lion statue with Chinese style

watercolor painting, Dean Mitchell

Fisherman and the devil, Leonardo da Vinci

"Keanu Reeves,Cyberpunk 2077"

Doctor Manhattan, Watchman

AI 画画及 prompt

如果你不太清楚该怎么向你的AI工具念咒语,可以参考下面的资料。

The DALL·E 2 Prompt Book View the full book full-screen Or download the PDF.

6pen 使用手册

嫌麻烦的,有在线工具可以体验。

Tag:AI Published under (CC) BY-NC-SA