# Stylized Neural Painting
[Preprint](<https://arxiv.org/abs/2011.08114>) | [Project Page](<https://jiupinjia.github.io/neuralpainter/>) | [Colab Runtime 1](<https://colab.research.google.com/drive/1XwZ4VI12CX2v9561-WD5EJwoSTJPFBbr?usp=sharing/>) | [Colab Runtime 2](<https://colab.research.google.com/drive/1ch_41GtcQNQT1NLOA21vQJ_rQOjjv9D8?usp=sharing/>)
### Official Pytorch implementation of the preprint paper "Stylized Neural Painting", in arXiv:2011.08114.
We propose an image-to-painting translation method that generates vivid and realistic painting artworks with controllable styles. Different from previous image-to-image translation methods that formulate the translation as pixel-wise prediction, we deal with such an artistic creation process in a vectorized environment and produce a sequence of physically meaningful stroke parameters that can be further used for rendering. Since a typical vector render is not differentiable, we design a novel neural renderer which imitates the behavior of the vector renderer and then frame the stroke prediction as a parameter searching process that maximizes the similarity between the input and the rendering output. Experiments show that the paintings generated by our method have a high degree of fidelity in both global appearance and local textures. Our method can be also jointly optimized with neural style transfer that further transfers visual style from other images.
![](./gallery/gif_teaser_1.gif)
In this repository, we implement the complete training/inference pipeline of our paper based on Pytorch and provide several demos that can be used for reproducing the results reported in our paper. With the code, you can also try on your own data by following the instructions below.
The implementation of the sinkhorn loss in our code is partially adapted from the project [SinkhornAutoDiff](https://github.com/gpeyre/SinkhornAutoDiff).
### License
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title"> Stylized Neural Painting</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www-personal.umich.edu/~zzhengxi/">Zhengxia Zou</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
### One-min video result
[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/oerb-nwrXhk/0.jpg)](https://www.youtube.com/watch?v=oerb-nwrXhk)
## Requirements
See [Requirements.txt](Requirements.txt).
## Setup
1. Clone this repo:
```bash
git clone https://github.com/jiupinjia/stylized-neural-painting.git
cd stylized-neural-painting
```
2. Download one of the pretrained neural renderers from Google Drive (1. [oil-paint brush](https://drive.google.com/file/d/1sqWhgBKqaBJggl2A8sD1bLSq2_B1ScMG/view?usp=sharing), 2. [watercolor ink](https://drive.google.com/file/d/19Yrj15v9kHvWzkK9o_GSZtvQaJPmcRYQ/view?usp=sharing), 3. [marker pen](https://drive.google.com/file/d/1XsjncjlSdQh2dbZ3X1qf1M8pDc8GLbNy/view?usp=sharing), 4. [color tapes](https://drive.google.com/file/d/162ykmRX8TBGVRnJIof8NeqN7cuwwuzIF/view?usp=sharing)), and unzip them to the repo directory.
```bash
unzip checkpoints_G_oilpaintbrush.zip
unzip checkpoints_G_rectangle.zip
unzip checkpoints_G_markerpen.zip
unzip checkpoints_G_watercolor.zip
```
## To produce our results
#### Photo to oil painting
![](./gallery/apple_oilpaintbrush.jpg)
- Progressive rendering
```bash
python demo_prog.py --img_path ./test_images/apple.jpg --canvas_color 'white' --max_m_strokes 500 --max_divide 5 --renderer oilpaintbrush --renderer_checkpoint_dir checkpoints_G_oilpaintbrush
```
- Rendering directly from mxm image grids
```bash
python demo.py --img_path ./test_images/apple.jpg --canvas_color 'white' --max_m_strokes 500 --m_grid 5 --renderer oilpaintbrush --renderer_checkpoint_dir checkpoints_G_oilpaintbrush
```
#### Photo to marker-pen painting
![](./gallery/diamond_markerpen.jpg)
- Progressive rendering
```bash
python demo_prog.py --img_path ./test_images/diamond.jpg --canvas_color 'black' --max_m_strokes 500 --max_divide 5 --renderer markerpen --renderer_checkpoint_dir checkpoints_G_markerpen
```
- Rendering directly from mxm image grids
```bash
python demo.py --img_path ./test_images/diamond.jpg --canvas_color 'black' --max_m_strokes 500 --m_grid 5 --renderer markerpen --renderer_checkpoint_dir checkpoints_G_markerpen
```
#### Style transfer
![](./gallery/nst.jpg)
- First, you need to generate painting and save stroke parameters to output dir
```bash
python demo.py --img_path ./test_images/sunflowers.jpg --canvas_color 'white' --max_m_strokes 500 --m_grid 5 --renderer oilpaintbrush --renderer_checkpoint_dir checkpoints_G_oilpaintbrush --output_dir ./output
```
- Then, choose a style image and run style transfer on the generated stroke parameters
```bash
python demo_nst.py --renderer oilpaintbrush --vector_file ./output/sunflowers_strokes.npz --style_img_path ./style_images/fire.jpg --content_img_path ./test_images/sunflowers.jpg --canvas_color 'white' --renderer_checkpoint_dir checkpoints_G_oilpaintbrush --transfer_mode 1
```
You may also specify the --transfer_mode to switch the transfer mode (0: transfer color only, 1: transfer both color and texture)
Also, please note that in the current version, the style transfer are not supported by the progressive rendering mode. We will be working on this feature in the near future.
#### Generate 8-bit graphic artworks
![](./gallery/8bitart.jpg)
```bash
python demo_8bitart.py --img_path ./test_images/monalisa.jpg --canvas_color 'black' --max_m_strokes 300 --max_divide 4
```
## Google Colab
Here we also provide a minimal working example of the inference runtime of our method. Check out the following runtimes and see your result on Colab.
[Colab Runtime 1](https://colab.research.google.com/drive/1XwZ4VI12CX2v9561-WD5EJwoSTJPFBbr?usp=sharing/) : Image to painting translation (progressive rendering)
[Colab Runtime 2](https://colab.research.google.com/drive/1ch_41GtcQNQT1NLOA21vQJ_rQOjjv9D8?usp=sharing/) : Image to painting translation with image style transfer
## To retrain your neural renderer
You can also choose a brush type and train the stroke renderer from scratch. The only thing to do is to run the following common. During the training, the ground truth strokes are generated on-the-fly, so you don't need to download any external dataset.
```bash
python train_imitator.py --renderer oilpaintbrush --net_G zou-fusion-net --checkpoint_dir ./checkpoints_G --vis_dir val_out --max_num_epochs 400 --lr 2e-4 --batch_size 64
```
## Citation
If you use this code for your research, please cite our paper:
``````
@inproceedings{zou2020stylized,
title={Stylized Neural Painting},
author={Zhengxia Zou and Tianyang Shi and Shuang Qiu and Yi Yuan and Zhenwei Shi},
year={2020},
eprint={2011.08114},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
``````
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip 【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于python深度学习的油画创作系统设计与实现(通过建立深度卷积神经网络来模拟画家进行艺术的创作).zip (153个子文件)
artur.jpg 951KB
login3.jpg 610KB
nst.jpg 577KB
ai-6-3.jpg 330KB
apple_oilpaintbrush.jpg 292KB
8bitart.jpg 211KB
diamond_markerpen.jpg 192KB
mosaic.jpg 189KB
apple.jpg 93KB
yosemite.jpg 72KB
sunflower (2).jpg 69KB
picasso.jpg 65KB
sunflowers.jpg 58KB
fire.jpg 54KB
fire.jpg 54KB
photo371589.jpg 54KB
jay.jpg 49KB
joker.jpg 47KB
pr2.jpg 44KB
photo1048035.jpg 43KB
sunflower.jpg 41KB
photo1458377.jpg 39KB
iceland.jpg 39KB
scream.jpg 39KB
photo409696.jpg 38KB
photo1082663.jpg 36KB
alien.jpg 35KB
photo1070860.jpg 34KB
pr1.jpg 32KB
diamond.jpg 31KB
ss.jpg 30KB
sd.jpg 26KB
b.jpg 25KB
diamond2.jpg 25KB
photo129574.jpg 24KB
photo46710.jpg 24KB
cube2.jpg 19KB
test.jpg 11KB
README.md 7KB
joker_input.png 583KB
diamond_input.png 486KB
fire_input.png 428KB
photo46710_input.png 391KB
sunflower_input.png 390KB
photo46710_rendered_stroke_.png 372KB
photo1048035_rendered_stroke_.png 370KB
photo1082663_rendered_stroke_.png 357KB
photo1048035_input.png 353KB
sunflower_rendered_stroke_.png 351KB
artur_input.png 349KB
photo1082663_input.png 344KB
joker_rendered_stroke_.png 332KB
diamond_rendered_stroke_.png 330KB
artur_rendered_stroke_.png 307KB
cube2_rendered_stroke_.png 260KB
fire_rendered_stroke_.png 260KB
cube2_input.png 230KB
customer2.png 59KB
brush_fromweb2_large_horizontal.png 47KB
brush_fromweb2_large_vertical.png 45KB
staff3.png 31KB
hotel.png 22KB
search1.png 18KB
coffee.png 17KB
room4.png 17KB
export.png 16KB
staff.png 16KB
delete.png 14KB
brush_fromweb2_small_vertical.png 12KB
room2.png 12KB
order.png 12KB
brush_fromweb2_small_horizontal.png 11KB
search.png 11KB
insert.png 9KB
room1.png 8KB
room5.png 6KB
staff5.png 3KB
chart.png 3KB
room3.png 3KB
ask.png 3KB
staff4.png 3KB
staff2.png 3KB
tobecontinued.png 3KB
login.png 2KB
staff.py 37KB
report.py 26KB
networks.py 15KB
renderer.py 14KB
painter.py 14KB
utils.py 11KB
album_interface.py 11KB
MainUI.py 9KB
imitator.py 9KB
Main.py 8KB
pop_up_ani_stacked_widget.py 7KB
ForgetPwd.py 7KB
MainMenu.py 7KB
ModifyPwd.py 7KB
test.py 7KB
loss.py 6KB
共 153 条
- 1
- 2
资源评论
龙年行大运
- 粉丝: 1255
- 资源: 3844
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功