Learning to Paint With Model-Based Deep Reinforcement Learning

Zhewei Huang, Shuchang Zhou, Wen HengICCV 2019

Abstract

We demonstrate a method for teaching machines to paint in a human-like manner, using a limited number of brushstrokes to reconstruct complex images. By integrating a differentiable neural renderer into a model-based Deep Reinforcement Learning (DRL) framework, our agents learn to determine stroke parameters—such as position, color, and shape—and perform long-term planning to decompose texture-rich images. Our experiments show that high-quality visual effects can be achieved with just a few hundred strokes, without requiring human artistic data or stroke tracking.

Introduction: The Challenge of Stroke-Based Rendering

Most modern AI image generation, such as standard Generative Adversarial Networks (GANs), operates at the pixel level, essentially "printing" an image in a single pass. In contrast, human painting is a sequential, stroke-based process known as Stroke-Based Rendering (SBR). Replicating this process computationally presents two major hurdles:

  1. The Planning Problem: Determining which stroke to place at the beginning to achieve a specific visual goal hundreds of steps later is a massive search problem.
  2. The Differentiability Gap: Traditional painting simulators are non-differentiable "black boxes." It is difficult to provide gradient-based feedback to an AI agent because the physical simulation of paint on canvas cannot be easily backpropagated through.

Previous model-free RL approaches, like SPIRAL, often struggle with sample inefficiency and the high-dimensional continuous parameter space required for realistic strokes.

Methodology: Model-Based DRL and Neural Rendering

To overcome these challenges, we propose a model-based DRL framework. The core innovation is a Neural Renderer—a deep neural network trained to simulate the rendering of stroke parameters onto a canvas. Because this renderer is a neural network, it is fully differentiable, allowing for direct gradient feedback.

The proposed framework: (a) illustrates the sequential painting process where a policy predicts actions to update a canvas; (b) details the RL architecture including the Actor, Critic, Discriminator, and differentiable Renderer.

The architecture utilizes several key components:

  • Deep Deterministic Policy Gradient (DDPG): This handles the continuous action space of stroke parameters (position, shape, color, transparency).
  • Action Bundling: The agent predicts a bundle of $k=5$ strokes simultaneously, encouraging the exploration of stroke combinations and accelerating the rendering process.
  • WGAN Reward: Instead of a simple pixel-wise $L_2$ loss, which often results in blurriness, we employ a Wasserstein GAN discriminator. This provides a reward signal based on high-level visual similarity and style.
  • CoordConv: Integrated into the actor and critic networks to improve the agent's spatial coordinate understanding.

Results and Key Insights

The agent was evaluated across four diverse datasets: MNIST (5 strokes), SVHN (40 strokes), CelebA (200 strokes), and ImageNet (400 strokes).

The agent naturally learns a coarse-to-fine strategy across various datasets, starting with large background strokes and progressing to fine details.

Our findings highlight several critical advantages of this approach:

  • Differentiability as a Catalyst: By using a neural renderer, the agent receives direct gradient feedback, achieving significantly lower error rates than model-free methods. Ablation studies showed our model-based DDPG outperformed model-free versions by up to 20x in convergence speed and final error.
  • Emergent Coarse-to-Fine Strategy: Interestingly, the agent naturally adopted a human-like strategy: laying down large, opaque strokes for backgrounds and basic shapes before using smaller, more transparent strokes for fine details.
  • Adversarial Visual Quality: The WGAN reward proved essential for artistic coherence. While $L_2$ loss might minimize mathematical distance, the adversarial reward produced paintings that were more vivid and visually appealing.

Conclusion and Future Work

Our model-based DRL approach successfully bridges the gap between pixel-based generation and human-like stroke-based rendering. While the agent handles complex textures well, very fine-grained details (like individual hairs) remain challenging within a limited stroke budget. Future research could explore more diverse brush types, physical paint mixing simulations, and real-time interactive painting architectures.

Summary updated

BibTeX
@inproceedings{huang2019learning,
  author = {Zhewei Huang and Shuchang Zhou and Wen Heng},
  title = {{Learning to Paint With Model-Based Deep Reinforcement Learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2019},
  url = {https://openreview.net/forum?id=DtgqRjsJ4jC},
}
Figure