hzwer/ICCV2019-LearningToPaint
hzwer/ICCV2019-LearningToPaint has 2,317 GitHub stars and 312 forks. GitHot measured 0 stars in 24 hours and +2 in 7 days. Last checked 2026-11-05 14:58 UTC. Last push 2025-05-07.
ICCV2019 - Learning to Paint With Model-based Deep Reinforcement Learning
Measured star growth
- in 24h
- 0
- in 7 days
- +2
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalICCV2019-Learning to Paint
arXiv | YouTube | Reddit | Slide(中文) | DeepWiki | Replicate
Zhewei Huang, Wen Heng, Shuchang Zhou
Abstract
We show how to teach machines to paint like human painters, who can use a small number of strokes to create fantastic paintings. By employing a neural renderer in model-based Deep Reinforcement Learning (DRL), our agents learn to determine the position and color of each stroke and make long-term plans to decompose texture-rich images into strokes. Experiments demonstrate that excellent visual effects can be achieved using hundreds of strokes. The training process does not require the experience of human painters or stroke tracking data.
You can easily use colaboratory to have a try.





Dependencies
- PyTorch 1.1.0
- tensorboardX
- opencv-python 3.4.0
pip3 install torch==1.1.0
pip3 install tensorboardX
pip3 install opencv-python
Testing
Make sure there are renderer.pkl and actor.pkl before testing.
You can download a trained neural renderer and a CelebA actor for test: renderer.pkl and actor.pkl
$ wget "https://drive.google.com/uc?export=download&id=1-7dVdjCIZIxh8hHJnGTK-RA1-jL1tor4" -O renderer.pkl
$ wget "https://drive.google.com/uc?export=download&id=1a3vpKgjCVXHON4P7wodqhCgCMPgg1KeR" -O actor.pkl
$ python3 baseline/test.py --max_step=100 --actor=actor.pkl --renderer=renderer.pkl --img=image/test.png --divide=4
$ ffmpeg -r 10 -f image2 -i output/generated%d.png -s 512x512 -c:v libx264 -pix_fmt yuv420p video.mp4 -q:v 0 -q:a 0
(make a painting process video)
We also provide with some other neural renderers and agents, you can use them instead of renderer.pkl to train the agent:
triangle.pkl --- actor_triangle.pkl;
round.pkl --- actor_round.pkl;
bezierwotrans.pkl --- actor_notrans.pkl
We also provide 百度网盘 source. 链接: https://pan.baidu.com/s/1GELBQCeYojPOBZIwGOKNmA 提取码: aq8n
Training
Datasets
Download the CelebA dataset and put the aligned images in data/img_align_celeba/******.jpg
Neural Renderer
To create a differentiable painting environment, we need train the neural renderer firstly.
$ python3 baseline/train_renderer.py
$ tensorboard --logdir train_log --port=6006
(The training process will be shown at http://127.0.0.1:6006)
Paint Agent
After the neural renderer looks good enough, we can begin training the agent.
$ cd baseline
$ python3 train.py --max_step=40 --debug --batch_size=96
(A step contains 5 strokes in default.)
$ tensorboard --logdir train_log --port=6006
Resources
- Our ICCV poster
- Our ICCV rebuttal for reviewers
Contributors
Also many thanks to ctmakro for inspiring this work. He also explored using greedy algorithm to generate paintings - opencv_playground.
If you find this repository useful for your research, please cite the following paper:
@inproceedings{huang2019learning,
title={Learning to paint with model-based deep reinforcement learning},
author={Huang, Zhewei and Heng, Wen and Zhou, Shuchang},
booktitle={Proceedings of the IEEE International Conference on Computer Vision (ICCV)},
year={2019}
}
Explore related projects
tensorflow/tensorflow
An Open Source Machine Learning Framework for Everyone
201,311 starshuggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
168,576 starsAUTOMATIC1111/stable-diffusion-webui
Stable Diffusion web UI
165,264 starsComfy-Org/ComfyUI
The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
145,310 stars