Diverse Rare Sample Generation with Pretrained GANs

Subeen Lee, Jiyeon Han, Soyeon Kim, Jaesik Choi

TL;DR

This paper introduces a novel method to generate diverse, high-fidelity "rare" samples from pretrained GANs without requiring any model retraining or fine-tuning. By optimizing latent vectors within a multi-objective framework guided by normalizing flows, the approach successfully uncovers underrepresented data variations (like extreme ages or unique accessories) while maintaining image quality and similarity to a reference image.

What Problem Does This Paper Address?

Deep generative models like Generative Adversarial Networks (GANs) excel at producing highly realistic images. However, they suffer from a major drawback: they tend to ignore the "long tail" of the data distribution. Due to limited representation in training sets and the notorious problem of mode collapse, GANs struggle to generate rare samples or edge cases (e.g., people wearing unique hats, uncommon head poses, or rare animal breeds).

While existing methods attempt to fix this, they usually require computationally expensive retraining or fine-tuning. Post-processing alternatives, such as resampling techniques, often sacrifice image fidelity or require massive sampling pools to be effective. This paper tackles the challenge of directly navigating a pretrained GAN's latent space to discover diverse, high-quality, and rare variations of a given reference image.

Methods

Instead of altering the GAN itself, the authors propose a gradient-based optimization strategy in the model's latent space. Given a reference image's latent vector, the goal is to find a set of new latent vectors that produce rare but realistic variations.

The core framework relies on three main components:

  1. Differentiable Density Estimation via Normalizing Flows (NFs): Traditional rarity metrics rely on non-differentiable $k$-nearest neighbor ($k$-NN) distances, making gradient-based optimization impossible. The authors solve this by training a Glow-based Normalizing Flow model on a high-level feature space (extracted from a pretrained VGG16 network). The NF provides an exact, differentiable log-likelihood ($\log p(x)$), allowing the system to minimize density and directly push images toward rare regions.
  2. Multi-Start Optimization with a Diversity Constraint: To generate multiple distinct rare versions rather than converging on the same local minimum, the method initializes optimization from multiple points by adding small random noise to the reference latent vector. Crucially, they introduce a diversity loss ($\mathcal{L}_{div}$) that penalizes pairs of generated images for being too close to each other in the feature space.
  3. Similarity and Fidelity Constraints: To prevent the optimization from generating unrealistic artifacts or drifting completely away from the reference identity, the objective function includes a similarity loss ($\mathcal{L}_{sim}$) and strictly constrains the optimization path to stay within the real data manifold defined by a $k$-NN boundary.
Schematic diagram of the multi-objective framework combining rarity, diversity, and similarity constraints.

Datasets

The method was validated on several high-resolution ($1024 \times 1024$) image datasets using StyleGAN2 and StyleGAN2-ADA architectures:

  • Flickr Faces HQ (FFHQ): Human face dataset used to evaluate rare facial attributes.
  • Animal Faces HQ (AFHQ) Cat & Dog: Used to evaluate rare animal breeds and expressions.
  • MetFaces: A dataset of painted faces from artwork, used to test domain generalization.

Key Insights and Ideas

  • Feature-Space Normalizing Flows: Training NFs directly on pixels often fails because the model focuses on low-level textures rather than semantic meaning. Training the NF on a pretrained embedding space (VGG16-fc2) allows it to model semantic rarity effectively.
  • The Multi-Start Pitfall: Simply starting gradient descent from slightly different noisy initializations is not enough; without an explicit diversity penalty ($\mathcal{L}_{div}$), the vectors eventually converge to identical local optima.
  • NF as a Proxy for $k$-NN Rarity: The authors discovered a remarkably high Pearson correlation (0.928 for real samples) between the differentiable NF log-likelihood and traditional non-differentiable $k$-NN rarity scores, validating NFs as an excellent proxy for optimization.

Key Results

The proposed method successfully shifts the generated data distribution toward rare attributes without destroying image quality.

Quantitative Performance

Compared to the baseline and Polarity Sampling (a state-of-the-art resampling method), the proposed approach achieved superior balance across metrics on the FFHQ dataset:

  • Rarity Score (RS): Improved from 18.88 (Baseline) to 23.50.
  • Precision (Fidelity): Reached 0.92, significantly outperforming Polarity Sampling (0.39), which frequently generated out-of-manifold artifacts.
  • Diversity (LPIPS): Increased from 0.73 (Baseline) to 0.76.

Qualitative Performance

Using attribute classifiers, the authors proved that their method significantly increased the frequency of rare traits. For example, in the FFHQ dataset, the percentage of generated images containing a "Wearing Hat" attribute increased from 8.07% in the baseline to 11.03%, and "Pale Skin" tripled from 0.12% to 0.37%.

Figure 1: Examples of rare samples generated by our method. Left: Our method produces diverse rare images for a single reference, with variations even within the same rare attribute (e.g., hats of different shapes and colors). Right: Generated rare attributes include accessories like hats, non-brown hair colors, extreme ages, and non-white races. “Pose” refers to head orientation, and “Acc.” denotes accessories. Rare attributes are highlighted in bold.

Limitations and Future Work

  • GAN Dependency: The method is strictly bounded by the capabilities of the pretrained GAN. If the underlying GAN cannot model a specific feature at all, this optimization framework cannot magically create it.
  • Coarse Attribute Control: The optimization alters multiple semantic attributes simultaneously (e.g., changing hair color and head pose at the same time). The authors suggest that integrating this approach with explicit image manipulation techniques could allow for more targeted, user-controlled rare attribute generation.
  • Computational Overhead: Running gradient-based optimization per reference image takes under 8 minutes on a single GPU, which is efficient but slower than direct feed-forward sampling methods.

Summary updated

BibTeX
@inproceedings{lee2025diverse,
  author = {Subeen Lee and Jiyeon Han and Soyeon Kim and Jaesik Choi},
  title = {{Diverse Rare Sample Generation with Pretrained GANs}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i5.32480},
}
Figure