Modelling complex vector drawings with stroke-clouds

Alexander Ashcroft, Ayan Das, Yulia Gryaditskaya, Zhiyu Qu, Yi-Zhe SongICLR 2024

Introduction

Vector graphics are the gold standard for digital art due to their infinite scalability and ease of editing. However, teaching AI to generate them has proven surprisingly difficult. This paper introduces a novel approach that moves away from treating vector drawings as sequential pen movements. Instead, it represents them as "stroke clouds"—unordered sets of Bézier curves. By combining set-based encoding with latent diffusion models, this framework successfully generates and reconstructs complex anime line art, far exceeding the complexity limits of traditional sequential models.

The Challenge of Complex Vector Art

Most existing generative models for vector graphics, such as SketchRNN, treat a drawing as a sequence of pen movements. While this auto-regressive approach works well for simple icons (like a sun or a house), it fails significantly as drawings increase in complexity.

Sequential models like RNNs or Transformers suffer from "long-range dependency" issues. As the number of strokes increases, the model often "forgets" the beginning of the drawing or fails to maintain global structural coherence. Consequently, most current benchmarks, like Google’s QuickDraw, average only about five strokes per image. This research aims to bridge the gap to truly "complex" drawings, such as portraits and illustrations that contain hundreds of individual strokes.

Methodology: The Stroke Cloud Approach

To overcome the limitations of sequential generation, the authors propose a two-stage generative framework that entirely abandons the concept of stroke order.

1. Stroke Cloud Representation: A drawing is defined as an unordered set of $N$ strokes, where each stroke is a quadratic Bézier curve. Because it is treated as a set, the order in which strokes are stored or drawn is irrelevant.

2. Stroke Cloud Representation Module (SRM): This module acts as an autoencoder for sets.

  • Encoder: It utilizes a Set Transformer that is permutation-invariant, meaning it produces the identical latent code $z$ regardless of the input stroke order.
  • Decoder: An MLP-based diffusion model treats each stroke as an independent sample conditioned on the global latent code $z$. This approach is mathematically grounded in De-Finetti’s Theorem of Exchangeability, which posits that elements of a set can be modeled as independent and identically distributed (I.I.D.) if they are conditioned on a shared underlying latent variable.

3. Latent Stroke Cloud Generator (LSG): Once the SRM successfully compresses drawings into a compact latent space, a second diffusion model (the LSG) is trained to generate new, valid latent codes from scratch, effectively capturing the distribution of complex vector drawings on an implicit set space.

Datasets

Because no large-scale dataset of complex vector art existed, the authors created Anime-Vec10k. They processed 10,000 anime portraits from the Danbooru2019 dataset, converted them to sketches using a GAN, and vectorized them. These resulting sketches average 305 strokes each—roughly 60 times more complex than the QuickDraw dataset. QuickDraw was still utilized as a baseline to demonstrate that the model remains effective on simpler, hand-drawn data.

Key Insights

  • The "Set" Advantage: By treating a drawing as a cloud of strokes rather than a sequence, the model avoids the vanishing gradient and attention drift problems inherent to sequential models. The model does not need to learn whether to draw the eyes before the hair; it simply generates the set.
  • Over-sampling for Quality: Because the decoder treats strokes as I.I.D. samples, users can ask the model to generate more strokes than were present in the original training data. This "over-sampling" often leads to more complete-looking drawings and can mimic a shading effect.
  • Spectral Bias Mitigation: MLPs often struggle to learn high-frequency details like fine lines. The authors mitigated this by using sinusoidal positional embeddings for the Bézier control points, significantly improving the crispness of the reconstructed drawings.

Results and Capabilities

The model successfully generated anime faces with high fidelity, a task previously considered out of reach for pure vector generative models.

Reconstruction and Generation of complex anime vector art

In quantitative tests, the model achieved its best reconstruction performance when sampling 1,000 strokes, reaching an FID score of 9.8. Furthermore, the authors demonstrated smooth latent space interpolation. They could "morph" one drawing into another by interpolating between their latent codes, with intermediate steps remaining semantically coherent (e.g., a face gradually changing shape). This proves the model learned a deeply meaningful representation of the dataset's visual characteristics.

Limitations and Future Work

Despite its success, the model has a few notable limitations. First, it suffers from unknown cardinality; the model does not inherently know how many strokes a drawing should have, leaving the number of strokes to sample ($N$) as a user-defined hyperparameter. Second, because strokes are generated independently, the model lacks stroke continuity. It does not naturally connect the end of one stroke to the start of another to form long, continuous lines, resulting in many short, overlapping segments. Finally, the Anime-Vec10k dataset relies on synthetic vectorization. Real human-drawn vector art often uses fewer, more purposeful strokes, making training on authentic human-authored complex vector data a primary goal for future research.

Summary updated

BibTeX
@inproceedings{ashcroft2024modelling,
  author = {Alexander Ashcroft and Ayan Das and Yulia Gryaditskaya and Zhiyu Qu and Yi-Zhe Song},
  title = {{Modelling complex vector drawings with stroke-clouds}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=O2jyuo89CK},
}
Figure