Abstract
Generating high-quality vector sketches from images has traditionally been a trade-off between speed and artistic fidelity. While optimization-based methods using Score Distillation Sampling (SDS) produce professional-grade results, their multi-minute inference times limit practical application. We present SwiftSketch, a transformer-decoder-based diffusion model that generates editable vector sketches in under a second. By distilling the knowledge of a slow optimization-based "teacher" into a fast feed-forward "student" model using a novel synthetic dataset of 35,000 image-sketch pairs, SwiftSketch achieves state-of-the-art performance with a 600x speedup over existing methods.
1. Introduction
In the realm of computer vision, converting a raster image into a line drawing is a foundational task. While pixel-based edge detection is trivial, generating vector sketches (Scalable Vector Graphics) remains a significant challenge. Vector sketches are highly valued by designers because they are resolution-independent, easily editable, and mimic the sequential, abstract nature of human drawing.
Recent advancements in Vision-Language Models (VLMs) have enabled the generation of beautiful vector sketches through iterative optimization. However, these methods—such as CLIPasso—rely on Score Distillation Sampling (SDS), which requires hundreds of optimization steps per image. This results in inference times ranging from 5 to 10 minutes, making them unsuitable for real-time creative workflows. SwiftSketch addresses this bottleneck by replacing slow optimization with a fast, conditional diffusion process.
2. Methodology
The development of SwiftSketch involved a two-stage pipeline: creating a high-quality synthetic dataset and training a specialized transformer-based diffusion model.
2.1 ControlSketch: The Data Generator
To train a supervised model, a large-scale dataset of paired images and professional-quality vector sketches is required. Existing datasets like Google’s QuickDraw are too simplistic, while professional datasets are too small. The authors developed ControlSketch, an improved optimization-based method, to act as a data generator. ControlSketch utilizes a depth-aware ControlNet to ensure the resulting sketch maintains the spatial structure of the source image. It also employs a smart stroke initialization strategy that balances visual saliency (via attention maps) with uniform spatial coverage. Using this method, the authors generated 35,000 high-quality image-sketch pairs.
2.2 SwiftSketch Architecture
SwiftSketch is a conditional diffusion model built on a transformer-decoder architecture. Unlike standard diffusion models that denoise pixels in a U-Net, SwiftSketch progressively denoises the control points of Bezier curves. The transformer-decoder is uniquely suited for this task as it can capture the long-range dependencies and topological relationships between different strokes.
The model is conditioned on CLIP image features and trained using a dual-loss function:
- Coordinate Loss (L1): Ensures the predicted Bezier control points match the ground truth vector data.
- Perceptual Loss (LPIPS): Applied to the rasterized version of the sketch to ensure the final visual output aligns with human perception.
Finally, a lightweight refinement network is applied to the output to snap strokes into place and remove residual noise from the diffusion process.
3. Key Insights
3.1 Distillation of Optimization
SwiftSketch demonstrates that the computational burden of SDS optimization can be shifted from inference to training. By using a slow "teacher" (ControlSketch) to build a dataset, the "student" (SwiftSketch) can learn to produce similar results in a single feed-forward pass.
3.2 Stroke Ordering and Abstraction
By heuristically sorting strokes in the training data (placing primary contours before fine details), the model implicitly learns a logical drawing order. This allows for controllable abstraction; a user can truncate the output SVG file to see a minimalist version of the sketch (e.g., using only the first 8 strokes) or a detailed version (using all 32 strokes).
4. Results
SwiftSketch achieves a massive reduction in latency, generating a complete vector sketch in approximately 0.5 seconds (comprising 50 diffusion steps and 1 refinement step). This is a significant improvement over CLIPasso (~5 minutes) and the teacher model, ControlSketch (~10 minutes).
In terms of quality, SwiftSketch maintains high fidelity to the source images. On categories included in the training set, it achieved a 0.95 CLIP Top-1 accuracy score, nearly matching the 0.97 score of the much slower ControlSketch. Furthermore, a human preference study revealed that evaluators preferred the outputs of the SwiftSketch pipeline over CLIPasso 89% of the time.
5. Limitations and Future Work
While SwiftSketch represents a leap forward in speed, it faces challenges in generalization. Because the model was trained on a subset of 15 object categories, its performance degrades when processing highly out-of-distribution images, such as complex scenes or rare objects. Additionally, the refinement network can occasionally over-smooth the output, leading to the loss of minute details like facial features. Future iterations may explore dynamic stroke counts to allow for even greater flexibility in artistic abstraction.
Summary updated