Semantics-Preserving Sketch Embedding for Face Generation

Binxin Yang, Xuejin Chen, Chaoqun Wang, Chi Zhang, Zihan Chen, Xiaoyan Sun

TL;DR

This paper introduces a novel framework for generating photorealistic faces from sketches by combining the semantic stability of StyleGAN’s $W$ latent space with the high-fidelity reconstruction of the $W^+$ space. By incorporating a GNN-based module that interprets the "meaning" of individual strokes, the system ensures that generated images remain faithful to the user's intent—correctly rendering accessories like hats and glasses even in distorted, freehand drawings.

What Problem Does This Paper Address?

Sketch-to-image synthesis faces a major hurdle: sketches are sparse, often geometrically distorted, and semantically ambiguous. While modern GAN inversion techniques (like pSp or ReStyle) can map sketches to StyleGAN’s latent space, they often fail to preserve specific semantic details.

For example, if a user draws a hat or a specific pair of glasses, standard encoders might "hallucinate" hair or skin over those regions because those attributes are underrepresented in the training distribution. This happens because the high-degree-of-freedom $W^+$ space used for reconstruction is difficult to control precisely, leading to an entanglement of high-level semantics and low-level textures.

Methods

The authors propose a three-pronged approach to bridge the gap between rough strokes and photorealistic pixels:

  1. $W-W^+$ Hybrid Encoder: Instead of mapping directly to the complex $W^+$ space, the architecture uses two encoders. A $W$ encoder captures coarse semantic features (ensuring the "idea" of the face is correct), while a $W^+$ encoder captures fine-grained geometric details (the specific curves of the jaw or eyes). This balances controllability with reconstruction quality.
  2. Sketch Semantic Interpretation (SSI) Module: Rather than treating a sketch as a simple grid of pixels, this module treats it as a collection of vectors (strokes). It uses a Bidirectional GRU to extract features from point sequences and a Graph Neural Network (GNN) to understand the topological relationships between strokes. This allows the system to explicitly label a stroke as "nose," "glasses," or "hat" before generation begins.
  3. Semantic Feature Matching (SFM) Loss: To provide better supervision during training, the authors use a pre-trained face segmentation network. The loss function penalizes the model if the semantic map of the generated image doesn't match the semantic labels of the input sketch.

Datasets

  • CelebAMask-HQ: The primary source for raw face images and segmentation maps.
  • CelebA-Edge & CelebA-Contour: Two synthesized datasets created by the authors. "Edge" mimics detailed sketches, while "Contour" mimics concise, simplified drawings.
  • Freehand Sketches: A small testing set of sketches drawn by 30 non-expert volunteers to evaluate the model's generalization to real-world, distorted inputs.

Key Insights and Ideas

  • The Power of $W$ for Stability: The original $W$ space of StyleGAN is more "compact" and semantically meaningful than $W^+$. By forcing the coarse features into $W$, the model stays on the "manifold" of realistic faces, preventing the weird artifacts often seen in pure $W^+$ inversions.
  • Vectorized Sketches > Binary Bitmaps: By processing sketches as sequences of points (vectors), the model can leverage the temporal and structural order of drawing, which is much more informative for semantic classification than a static pixel grid.
  • Handling Minority Attributes: The explicit semantic labeling (SSI) and SFM loss specifically help the model handle "minority" classes like earrings or necklaces that are often ignored by standard MSE or perceptual losses.

Key Results

  • Quantitative: On the CelebA-Contour dataset, the proposed method achieved a FID of 43.18, significantly outperforming pSp (51.28) and ReStyle (75.17). It also achieved the highest semantic accuracy ($P_{Acc}$) of 0.892.
  • Qualitative: The model shows a remarkable ability to preserve "decoration strokes." While competing models often turn hats into hair or ignore glasses entirely, this method consistently renders them correctly, even when the input sketch is highly abstract or distorted.
  • Speed: Despite the complex architecture, the system is efficient, taking roughly 218ms to generate a $1024 \times 1024$ image on a standard GPU, making it suitable for interactive applications.

Limitations and Future Work

  • Geometric Alignment: Because the latent space is low-dimensional and compact, the final output might not perfectly align pixel-for-pixel with the input sketch (i.e., it is not a "conformal" mapping).
  • Color Entanglement: The model currently struggles to independently control the color of accessories versus hair. For instance, changing the hat color might inadvertently shift the hair color because these features are still somewhat entangled in the latent space.
  • Future Direction: The authors suggest exploring more granular control over local appearance and textures without sacrificing the global semantic consistency they have achieved here.

Summary updated

BibTeX
@article{yang2023semantics,
  author = {Binxin Yang and Xuejin Chen and Chaoqun Wang and Chi Zhang and Zihan Chen and Xiaoyan Sun},
  title = {{Semantics-Preserving Sketch Embedding for Face Generation}},
  journal = {IEEE Trans. Multimedia},
  year = {2023},
  doi = {10.1109/tmm.2023.3239182},
}
Figure