【christmAIs:用文本生成(节日贺卡上的)抽象图案】《Let AI design your holiday cards!》
项目介绍:https://stories.thinkingmachin.es/ai-art-holiday-cards/
GitHub地址:https://github.com/thinkingmachines/christmAIs
注意一定要点击文末的【阅读原文】才能打开本文的链接哦!
ChristmAIs(读音:“krees-ma-ees”)是一个能(在假期里)用文本生成抽象艺术图案的项目。
本项目可以通过以下方式将任何输入的字符串转换为抽象艺术:
使用GloVe找到Quick,Draw!中最相似的类;
使用叫做Sketch-RNN的变分自动编码器(VAE)绘制与之最接近的类;
以及将神经样式转移应用于生成的图像
生成的结果大概如下:
请注意 requirements.txt 和 requirements-dev.txt 适用于所有与Python相关的依赖项。 值得注意的依赖项包括:
numpy==1.14.2
scikit_learn==0.20.0
Pillow==5.3.0
matplotlib==2.1.0
tensorflow
gensim
magenta
你可以在Dockerfile中看到构建步骤(我们用来在云环境中执行自动构建的步骤)。 对于本地开发,建议设置一个虚拟环境。 为此,只需运行以下命令:
git clone git@github.com:thinkingmachines/christmAIs.gitcd christmAIs
make venv
我们创建了一个自动安装脚本,以便在工作区中执行一键安装设置。 要运行该脚本,请执行以下命令:
source venv/bin/activate # Highly recommended./install-christmais.sh
此步骤将会首先安装 magenta 及其依赖项,下载文件依赖项(categories.txt, model.ckpt 和 chromedriver),然后克隆并安装此软件包。
如果需要手动安装,请按照以下指示进行操作:
样式转换功能依赖于 magenta 包。目前, magenta 只支持Linux和Mac OS。要安装 magenta ,您可以执行自动安装或执行以下步骤:
#Install OS dependenciesapt-get update && \
apt-get install -y build-essential libasound2-dev libjack-dev#Install magentavenv/bin/pip install magenta
然后,你可以在 requirements.txt 中安装其余的依赖项。如果你已通过make venv 创建虚拟环境,我们建议你只需运行以下命令:
make build # or `make dev`
这也将(通过 wget )下载以下文件:
categories.txt(683 B):包含Quick,Draw的列表! 比较字符串的类别(将保存在./categories/categories.txt)。
arbitrary_style_transfer.tar.gz(606.20 MB):包含样式传输的模型检查点(将保存在./ckpt/model.ckpt)。
chromedriver(5.09 MB):包含用于访问Sketch-RNN的HTML输出的Web驱动程序(将保存在./webdriver/chromedriver中)。
确保已安装所有dev依赖项:
git clone git@github.com:thinkingmachines/christmAIs.gitmake venv
make dev
然后才能构建出实际的文档
cd christmAIs/docs/make html
运行命令后会生成一个 index.html 的文件,在浏览器打开就能浏览
我们提供了一个脚本christmais_time.py来轻松生成你的个性化Quick,Draw! 图片。 要使用它,只需运行以下命令:
python -m christmais.tasks.christmais_time \
--input=<Input string to draw from> \
--style=<Path to style image> \
--output=<Unique name of output file> \
--model-path=<Path to model.ckpt> \
--categories-path=<Path to categories.txt> \
--webdriver-path=<Path to webdriver>
如果您按照上面的设置说明操作,那么路径的默认值就足够了,您只需要提供--input, --style 和 --output.
举个例子,假设我想使用字符串 Thinking Machines 作为Ang Kiukok Fisherman 风格的基础(ang_kiukok.jpg),那么,我的命令将如下所示:
python -m christmais.tasks.christmais_time \
--input="Thinking Machines" \ --style=./path/to/ang_kiukok.png \ --output=tmds-output
然后就会生成并输出图片到./artifacts/:
Pennington, Jeffrey, Socher, Richard, et al. (2014). “Glove: Global Vectors for Word Representation”. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1532-1543.
Ha, David and Eck, Douglas (2017). “A Neural Representation of Sketch Drawings”. In: arXiv.:1704.03477.
Ghiasi, Golnaz et al. (2017). “Exploring the structure of real-time, arbitrary neural artistic stylization network”. In: arxiv:1705.06830.
Magenta demonstration (sketch-rnn.js):
https://github.com/hardmaru/magenta-demos/tree/master/sketch-rnn-js
【AI求职百题斩】每日挑战又双叒叕更新啦,赶紧来看题吧!
想知道正确答案?
回公众号聊天界面并发送“1227挑战”即可获取!
点击 阅读原文 查看本文更多内容↙