Disco Diffusion

1.说明

Discoart是基于Disco Diffusion的Python库,相比于配置Disco Diffusion,Discoart仅需在Python工程中使用pip命令安装即可,方便快捷。

Github链接:点击跳转

2.准备工作

  1. 安装Python3.7.6(64bit)
  2. 安装PyCharm(可选)
  3. 准备一台配置好点的电脑(显存最好有6G)

3.安装Discoart

接下来以PyCharm为例来实现安装。

新建一个Python工程,注意工程请放在磁盘空间较大的盘符。

然后执行命令:

pip install discoart

*pip安装可能会等很长时间,可以修改pip源为国内的镜像源后再执行上面的命令。

4.安装Pytorch CUDA版本

参考链接

5.运行

新建一个Python脚本,粘贴下面的命令:

from discoart import create

da = create(
    text_prompts='Nezha broke the clouds and looked at the surging waves. In the distance, there were dark clouds and the rocks were fierce. The red sky silk is fluttering and the golden heaven and earth circle is rotating. He is a hero!',
    skip_steps=10,
    steps=1000,
    n_batches=1,
    cutn_batches=1,
    width_height=[1024,768]
)

‘text_prompts’ 是描述文本
‘skip_steps’ 是跳过多少步
‘n_batches’ 是画几次
‘cutn_batches’ 暂时不清楚,但应该同上
‘width_height’ 是图片的宽高。

 

运行上面的代码后,首先会下载模型,如果电脑本地有模型了的话就不会下载了。下载模型所在的文件夹在:

 

模型的下载可能会很慢,等到模型下载完成后,就会看到有代码报错:

忽略掉这个错,它不会影响执行。
然后就能看到画画的进度条在缓慢的动了:

 

等模型下载完成后,就会开始绘画了,可以看到命令行窗口有进度条了。

6.绘画示例演示

让它画了个哪吒,关键词不太记得了,网上一搜一大把。