Abstract
Vector graphics are the gold standard for design due to their infinite scalability and ease of editing. However, training generative models for vectors is challenging because existing methods typically require "vector supervision"—datasets containing exact drawing commands (SVG paths). Such data is scarce and non-unique, as multiple path sequences can represent the same visual shape. We present Im2Vec, a novel deep learning framework that learns to generate complex vector graphics using only regular raster images for training. By incorporating a differentiable rasterization pipeline, Im2Vec eliminates the need for vector ground-truth data while outperforming existing models that require explicit vector supervision.
Introduction
Teaching AI to generate vector graphics is notoriously difficult. Unlike raster images, which are structured as grids of pixels, vector graphics are composed of mathematical paths and shapes. Traditional supervised models struggle with the ambiguity of vector representations. Im2Vec addresses this by asking: Can we learn to produce vectors just by looking at the final pixels?
As shown in the figure above, the model is capable of high-fidelity reconstruction, diverse font generation, and smooth interpolation between complex shapes like emojis, all while maintaining clean vector paths.
Methods
The authors propose an end-to-end variational autoencoder (VAE) architecture that bridges the gap between pixels and paths through several key components:
- The Encoder: A convolutional neural network (CNN) compresses a raster input image into a global latent code ($z$).
- The RNN Decoder: A Recurrent Neural Network decomposes the global code into individual latent codes ($z_t$) for each separate path or "layer" in the graphic.
- Path Decoder & Circular Convolutions: To ensure every generated path is a closed loop, the model treats each shape as a deformation of a unit circle. It uses circular 1D convolutions to process points along the perimeter, ensuring information flows around the entire shape.
- Adaptive Sampling: A sub-network "pushes" control points toward areas of high detail, such as sharp corners, allowing for more efficient and accurate representation of complex geometries.
- Differentiable Rasterization: This is the core innovation. Predicted vector paths are passed through a differentiable renderer (DiffVG). Because the rendering process is differentiable, the model can compare its rendered output to the target raster image and backpropagate the error to adjust the vector parameters.
- Multi-resolution Loss: Loss is calculated across an image pyramid to provide a stronger gradient signal, helping the model converge from coarse to fine details.
Key Insights and Results
Im2Vec was evaluated on four distinct datasets: FONTS, MNIST, EMOJIS, and ICONS.
Superior Reconstruction
Surprisingly, Im2Vec achieved better reconstruction results than fully supervised models. On the FONTS dataset, Im2Vec achieved a pixel-space reconstruction loss ($L_2$) of 0.0284, significantly outperforming DeepSVG (0.0938) and SVG-VAE (0.1322), despite the latter models having access to ground-truth vector data during training.
Latent Space Properties
Modeling shapes as deformed disks provides a natural correspondence between different objects. This allows for smooth latent space interpolation; for example, when morphing between different font styles, the "stem" of a digit naturally curls or straightens in a visually plausible way. Furthermore, the model can automatically predict the necessary number of Bézier segments for a path, balancing accuracy against file compactness.
Limitations and Future Work
While Im2Vec represents a significant step forward, it faces certain challenges:
- Resolution Underflow: Extremely fine details smaller than a single pixel at training resolution can be lost because the loss is calculated in pixel space.
- Local Optima: Without vector guidance, the model can occasionally produce "degenerate" geometries—shapes that look correct in pixels but contain messy or overlapping vector paths.
- Geometric Priors: Future work may incorporate local geometric priors, such as encouraging smoothness or symmetry, to produce even cleaner vector paths without requiring full supervision.
Conclusion
Im2Vec demonstrates that vector supervision is not a prerequisite for high-quality vector synthesis. By training on pixels via a differentiable renderer, the model learns the visual essence of shapes, bypassing the complexities of arbitrary SVG command sequences and setting a new state-of-the-art for unsupervised vector graphic generation.
Summary updated