Disco Diffusion 使用指南

Disco Diffusion 使用指南

在这里插入图片描述

介绍


Disco Diffusion 是在2021年2月初开始流行的一个 AI 图像生成程序, 使用多个不同的CLIP模型, 根据输入的描述关键词渲染出对应的图像. Disco Diffusion 可以在 Google Drive 中直接运行或者部署到本地运行.

快速使用


💡 在使用之前, 确保已注册谷歌账户.

1. 配置Google Colab

访问 Google Drive , 并登录谷歌账号. 依次点击 新建 > 更多 > 关联更多应用 > 搜索 Colaboratory 并添加 .

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649237928928-d732ff64-1b68-48b7-9f48-3bf405160949.png

访问Disco Diffusion Colab, 并保存副本至自己的Google Drive中, 稍后操作的都将在副本中执行.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649238449240-b6718418-377f-4991-af69-9f9d7d406360.png

保存副本后会自动跳转至副本项目.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649238632035-e4ea70ce-4c56-4d4b-976c-b6bd337df025.png

3. 代码简单介绍

我们首先将所有代码块折叠

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649247494642-d6dfccd3-100e-472a-9d5d-3543c6104fb0.png

可以看到DD v5.1主要有5个大的代码区块:

  1. Set Up : 负责环境配置
  2. Diffusion and CLIP model settings : 这组参数决定了在渲染图像时使用哪些模型
  3. Settings : 这里包含了 文图提示, 渲染, 初始化, 2D/3D动画… 一些最重要的参数.
  4. Diffuse! : 运行渲染
  5. Create the video : 制作动画

4. 修改默认设置参数

展开3.Settings代码区块, 根据自己的喜好修改参数设置.

  • Basic Setting (基础设置)

    此处不建议修改width_height参数, 图片设置的分辨率过高会超过服务器显存.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649240718560-b28df741-bac8-4004-966a-993c107bce79.png

  • Prompts (提示关键词)

    修改文本关键词, 提示词可以是几个单词, 几句话或者一大段话. 建议依照以下格式编写提示词. (提示词长度不要超过50) , 或者不修改直接使用默认的提示词.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649240890267-3d3c249e-e165-4a89-9562-b5ce7ac802b9.png

在这里插入图片描述

💡 Clouds surround the ancient Chinese palace on the hill, sunshine, dreams, overlooks, unreal engine, by Greg Rutkowski and James Gurney, trending on artstation

关于关键词的更深入解释请点击访问文本提示建议 / EZ-Charts .

5. Diffusion!

如果想时刻观察渲染进度, 可将display_rate的值设置为 5-10.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649242275625-5855f1b9-106b-4f67-a6d2-a874b9f8df3e.png

4. 运行所有代码块

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649242891499-a1684394-b560-4278-a5d2-ba439ab7fff3.png

在代码块4.Diffusion代码块运行时, 可以在该代码块下观察渲染进度

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649244348564-2be62bee-f76a-45bf-835f-c8a217990bfc.png

5. 图片渲染完成后, 会保存至以下位置.

我的云端硬盘 > AI > Disco_Diffusion > images_out > 自己定义的文件夹名

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649244835361-00adc10f-ff70-4de4-8fe7-0cc68ccfd6e7.png

在得到渲染图的同时, 会生成参数设置文档.

基础参数

💡 [250 | 10-1000] 表示: [ 默认值 | 取值范围 ]

3. Settings

  • Basic Settings :

    batch_name : 存放输出图片以及参数设置的文件夹名

    steps : [250 | 50-1000] 渲染的迭代步数. 值越高图片的细节越精细, 所花费时间也越长, 一般建议设置为 250-500 , 如果想更加精细可以设置1000以上. 超过500步效果逐渐降低.

    width_height : [1280, 768 | VRAM] 图片分辨率. 主要受显存限制. 不建议分辨率超过默认值. 常用的分辨率: [1280, 768] , [1280, 512], [720, 1280],

    clip_guidance_scale : [5000]

    tv_scale : [0]

    range_scale : [150 | 0-1000] 调整颜色对比度, 值越低对比度越高颜色越鲜艳. 值为 0 时停用此参数.

    set_scale : [0 | 0-1000] 饱和度, 值越低饱和度越高. 值为0时停用此参数.

    cutn_batches : [4 | 1-8]

    skip_augs :

  • Init Settings :

    init_image : 初始化图片路径. 设置初始图片将会把初始图像噪声替换掉, 你可以将skip_steps的值降低, 从而只保留初始图片的颜色和粗略的布局/形状. skip_steps的值越高保留的内容越多.

    Make sure you set skip_steps to ~50% of your steps if you want to use an init image.

    init_scale : [1000 | 10-2000]

    skip_steps : [10 | value<steps] 跳过指定步数(整数) 或者 保留指定步数的图像噪声/初始图片,

    如果只想参考初始图的构图, 可以将值设置为 [20% ~ 30%]。

    想保留初始图大部分的, 可以将值设置为[]

    clip_guidance_scale, steps 和 skip_steps 非常重要, 建议查阅 官方文档 加深理解.

https://cdn.nlark.com/yuque/0/2022/png/12759621/1649257651608-d2316aee-2e55-4d67-b815-c7a1e43f04e8.png

4. Diffuse!

display_rate : [50 | 5-500] 每隔指定步数输出一次预览图

n_batches : [50 | 1-100] 渲染图片的数量

resume_run : 恢复中断的运行, 但不会应用修改后的参数.

文本关键词

推荐格式 : 绘画风格 + (构图方式) + 主题元素 + 次要元素 + 风格 + 艺术家 + 艺术家所在平台

1. 尝试指定绘画风格

列如 : painting (油画), drawing (素描), sketch (速写), pencil drawing (铅笔画), woodblock print (木版画), matte painting (哑光油画), child’s drawing (儿童画), charcoal drawing (木炭画), a ink drawing (水墨画), oil on canvas (布面油画) , graffiti (涂鸦), watercolor painting (水彩画), fresco (壁画), stone tablet (石碑), cave painting (洞穴画) .

“A matte painting of a landscape” …

2. 尝试指定构图方式

列如 : portrait (人像), headshot (头像), ultrawide shot (超广角), extreme closeup (大特写镜头), macro shot (微距), an expansive view of (广阔视野)

“A portrait of a girl”, “A ultrawide shot of a landscape” …

3. 尝试添加风格描述词

列如 : Unreal engine (虚幻引擎), cyberpunk (赛博朋克), psychedelic (迷幻), surreal (超现实), vaporwave (蒸汽波), alien (外星人), solarpunk (太阳朋克), modern (现代), ancient , futuristic (未来主义), retro (复古), realistic (现实),dreamlike (梦幻), abstract (抽象), pop art (流行艺术), impressionism (印象艺术), minimalism (极简主义).

“A portrait of a girl, dreamlike” …

资源链接

  1. Disco Diffusion 官网* : https://discodiffusion.botbox.dev/
  2. 官方文档* : https://docs.google.com/document/d/1l8s7uS2dGqjztYSjPpzlmXLjl5PM3IGkRWI3IiCuK7g/edit
  3. Github* : https://github.com/alembics/disco-diffusion
  4. Colab* : https://colab.research.google.com/github/alembics/disco-diffusion/blob/main/Disco_Diffusion.ipynb#scrollTo=TitleTop
  5. 论坛* :
  6. DD EZ Charts* : https://docs.google.com/document/d/1ORymHm0Te18qKiHnhcdgGp-WSt8ZkLZvow3raiu2DVU/edit#heading=h.n7msa1nt9uri
  7. ArtStation 官网* : https://www.artstation.com/?sort_by=trending
  8. 油管UP Quick-Eyed Sky教程* : https://www.youtube.com/c/JPRobocat

最后再贴一张自己做的[二十四节气]

在这里插入图片描述