big-sleep - 一个用于文本到图像生成的简单命令行工具,使用 OpenAI 的 CLIP 和 BigGAN。

Created at: 2021-01-19 03:35:36
Language: Python
License: MIT

人工智能

宇宙的爱和关注

天空中的火

冰金字塔

树林里一座孤独的房子

山里的婚姻

雾蒙蒙的墓地树上挂着灯笼

生动的梦

城市废墟上空的气球

孤独的天文学家之死——莫拉奇

与自己永恒对话的悲惨亲密- by moirage

恶魔之火- 由WiseNat

大睡眠

赖恩·默多克做了一遍,结合OpenAI的CLIP并从发电机BigGAN!这个存储库包含了他的工作,因此任何拥有 GPU 的人都可以轻松访问它。

你将能够通过终端中的单行命令使用自然语言让 GAN 想象图像。

原装笔记本 在 Colab 中打开

简化笔记本 在 Colab 中打开

安装

$ pip install big-sleep

用法

$ dream "a pyramid made of ice"

图像将保存到调用命令的任何位置

先进的

你可以在代码中调用它

from big_sleep import Imagine

dream = Imagine(
    text = "fire in the sky",
    lr = 5e-2,
    save_every = 25,
    save_progress = True
)

dream()

你现在可以使用分隔符“|”训练多个短语

训练多个短语

在这个例子中,我们训练三个短语:

  • an armchair in the form of pikachu
  • an armchair imitating pikachu
  • abstract
from big_sleep import Imagine

dream = Imagine(
    text = "an armchair in the form of pikachu|an armchair imitating pikachu|abstract",
    lr = 5e-2,
    save_every = 25,
    save_progress = True
)

dream()

也会惩罚某些提示!

在这个例子中,我们训练之前的三个短语,

惩罚以下短语:

  • blur
  • zoom
from big_sleep import Imagine

dream = Imagine(
    text = "an armchair in the form of pikachu|an armchair imitating pikachu|abstract",
    text_min = "blur|zoom",
)
dream()

你还可以使用

.set_text(<str>)
命令设置新文本

dream.set_text("a quiet pond underneath the midnight moon")

并用

.reset()

dream.reset()

要在训练期间保存图像的进展,你只需提供

--save-progress
标志

$ dream "a bowl of apples next to the fireplace" --save-progress --save-every 100

由于 GAN 的类条件特性,Big Sleep 经常将流形转向噪音。你可以使用标志将得分最高的图像(每个 CLIP 评论家)保存到

{filepath}.best.png
你的文件夹中。

$ dream "a room with a view of the ocean" --save-best

实验

你可以使用以下

--max-classes
标志设置你希望限制 Big Sleep 用于 Big GAN 的类数(例如 15 个类)。这可能会导致训练期间的额外稳定性,但代价是失去表达能力。

$ dream 'a single flower in a withered field' --max-classes 15

备择方案

Deep Daze - CLIP 和深度 SIREN 网络

使用人

引文

@misc{unpublished2021clip,
    title  = {CLIP: Connecting Text and Images},
    author = {Alec Radford, Ilya Sutskever, Jong Wook Kim, Gretchen Krueger, Sandhini Agarwal},
    year   = {2021}
}
@misc{brock2019large,
    title   = {Large Scale GAN Training for High Fidelity Natural Image Synthesis}, 
    author  = {Andrew Brock and Jeff Donahue and Karen Simonyan},
    year    = {2019},
    eprint  = {1809.11096},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG}
}