CtlGAN: Few-shot Artistic Portraits Generation with Contrastive Transfer Learning

Yue Wang, Ran Yi, Luying Li, Ying Tai, Chengjie Wang, Lizhuang Ma

TL;DR

CtlGAN is a novel framework for few-shot artistic portrait generation that can adapt a pretrained StyleGAN2 to a new style using as few as 10 (or even just 1) target images. By introducing a Cross-Domain Triplet (CDT) loss and a specialized dual-path $Z+$ encoder, it generates high-quality, diverse stylized portraits that preserve the subject's identity while avoiding the common pitfall of overfitting to the small training set.

What Problem Does This Paper Address?

Generating high-quality artistic portraits (sketches, cartoons, caricatures) typically requires massive datasets of paired or unpaired images. When data is scarce—a "few-shot" scenario—traditional Image-to-Image (I2I) translation models tend to overfit.

Overfitting in this context often manifests as "mode collapse," where the model generates the same artistic face regardless of the input photo's identity. While recent transfer learning methods have tried to adapt pretrained GANs to small datasets, they often struggle to balance style accuracy with identity preservation. The authors of CtlGAN set out to bridge this gap: how can we teach a machine a new art style from a handful of examples without losing the unique features of the person being drawn?

Methods

CtlGAN consists of two main components: a Domain Adaptation Decoder and a Style Encoder.

1. Contrastive Transfer Learning (The Decoder)

The researchers adapted a StyleGAN2 pretrained on real faces (FFHQ) to a target artistic domain. To prevent the model from simply memorizing the few training images, they introduced the Cross-Domain Triplet (CDT) loss.

Unlike standard triplet losses, the CDT loss uses:

  • Anchor: A source image generated from a latent code ($G_s(z_i)$).
  • Positive: The target artistic image generated from the same code ($G_t(z_i)$).
  • Negative: Target artistic images generated from different latent codes ($G_t(z_j)$).

This explicitly forces the model to ensure that different people (different latent codes) result in different artistic portraits, effectively killing the "same-face" overfitting problem.

Fig. 4: (a) Few-Shot-GAN-Adaptation [33] framework and (b) Our contrastive transfer learning framework. Given a pretrained source generator and 10 target domain examples, Few-Shot-GAN-Adaptation adapts the model to the target domain by constraining the pairwise similarity before and after adaptation. While we explicitly enforce the target instances generated from two different latent codes to be different to prevent overfitting.

2. Dual-Path $Z+$ Encoder

To turn a real photo into a latent code the decoder understands, the authors proposed a new encoder. While most StyleGAN inversion uses the $W+$ space, the authors found that the $Z+$ space (an extended version of the initial latent space) better preserves structure during domain adaptation.

They also implemented a dual-path training strategy:

  • Path 1: Standard reconstruction of real faces.
  • Path 2 (Cycle Path): The encoder is trained on images synthesized by the GAN itself. This ensures the encoder's output follows a Gaussian distribution, making it perfectly compatible with the decoder's expectations.
Fig. 3: Our CtlGAN contains two parts, including a Style Encoder, and a Domain Adaptation Decoder which is based on StyleGAN2 [24]. We design a dual path training for our encoder with path-1 shown in blue and path-2 (cycle path) shown in orange.

Datasets

  • Source Domain: FFHQ (70,000 high-quality real face photos).
  • Target Domains (Few-shot):
    • Sketches: CUHK face sketch dataset.
  • Caricatures: Scraped from the web.
  • Cartoons: Toonify dataset.
  • Artistic Styles: Raphael and Roy Lichtenstein from the Artistic-Faces dataset.
  • Non-face domains: LSUN Cat and LSUN Church (to test generalizability).
  • Evaluation: 5,000 images from CelebA-HQ were used as test inputs.

Key Insights and Ideas

  • Diversity via Contrast: The "aha moment" is that few-shot GANs don't just need to learn the target style; they need to be reminded to stay diverse. The CDT loss acts as this reminder by penalizing the model if it tries to map different identities to the same stylized output.
  • $Z+$ is for Stylization: While $W+$ is the gold standard for perfectly reconstructing a specific photo, $Z+$ is more robust for transforming that photo. It maintains the "DNA" of the original StyleGAN better during the stressful process of domain adaptation.
  • The Power of 1-Shot: The model is surprisingly effective even with a single reference image, outperforming CLIP-based methods in identity preservation.

Key Results

CtlGAN significantly outperformed state-of-the-art (SOTA) methods like FSGA and StyleGAN-NADA across multiple metrics:

  • Quantitative: It achieved the lowest Fréchet Inception Distance (FID) on Sketches (49.85 vs. FSGA's 52.35) and Cartoon styles, indicating higher image quality and style similarity.
  • Qualitative: As seen in Figure 2, CtlGAN avoids the cluttered lines and identity loss seen in TGAN or Freeze-D.
  • User Study: In a blind test with 62 participants, CtlGAN's results were ranked as the best in 59.6% of cases, dwarfing the next best competitor (FSGA at 25.7%).
Qualitative comparison showing CtlGAN's superior identity preservation and diversity.

Limitations and Future Work

While CtlGAN excels at global style transfer, it has limitations in local editing. For example, when adapting to a "Sunglasses" domain, the model sometimes inadvertently changes the subject's haircut or skin details along with adding the glasses. The authors suggest that future work should focus on models that can decouple global style changes from local semantic editing.

Summary updated

Abstract

Generating artistic portraits is a challenging problem in computer vision. Existing portrait stylization models that generate good quality results are based on Image-to-Image Translation and require abundant data from both source and target domains. However, without enough data, these methods would result in overfitting. In this work, we propose CtlGAN, a new few-shot artistic portraits generation model with a novel contrastive transfer learning strategy. We adapt a pretrained StyleGAN in the source domain to a target artistic domain with no more than 10 artistic faces. To reduce overfitting to the few training examples, we introduce a novel Cross-Domain Triplet loss which explicitly encourages the target instances generated from different latent codes to be distinguishable. We propose a new encoder which embeds real faces into Z+ space and proposes a dual-path training strategy to better cope with the adapted decoder and eliminate the artifacts. Extensive qualitative, quantitative comparisons and a user study show our method significantly outperforms state-of-the-arts under 10-shot and 1-shot settings and generates high quality artistic portraits. The code will be made publicly available.
BibTeX
@misc{wang2022ctlgan,
  author = {Yue Wang and Ran Yi and Luying Li and Ying Tai and Chengjie Wang and Lizhuang Ma},
  title = {{CtlGAN: Few-shot Artistic Portraits Generation with Contrastive Transfer Learning}},
  year = {2022},
  eprint = {2203.08612},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.08612},
}
Figure