Controlling the Fidelity and Diversity of Deep Generative Models via Pseudo Density

Shuangqi Li, Chen Liu, Tong Zhang, Hieu Le, Sabine Susstrunk, Mathieu Salzmann

Abstract

We introduce an approach to bias deep generative models, such as GANs and diffusion models, towards generating data with either enhanced fidelity or increased diversity. Our approach involves manipulating the distribution of training and generated data through a novel metric for individual samples, named pseudo density, which is based on the nearest-neighbor information from real samples. Our approach offers three distinct techniques to adjust the fidelity and diversity of deep generative models: 1) Per-sample perturbation, enabling precise adjustments for individual samples towards either more common or more unique characteristics; 2) Importance sampling during model inference to enhance either fidelity or diversity in the generated data; 3) Fine-tuning with importance sampling, which guides the generative model to learn an adjusted distribution, thus controlling fidelity and diversity. Furthermore, our fine-tuning method demonstrates the ability to improve the Frechet Inception Distance (FID) for pre-trained generative models with minimal iterations.

Introduction

In the development of deep generative models, a persistent challenge is the trade-off between fidelity (the realism of individual samples) and diversity (the variety across the generated set). While models like GANs and diffusion models have achieved remarkable success, steering them toward specific points on the fidelity-diversity spectrum remains difficult. Existing methods, such as truncation in GANs, are often architecture-specific and lack a universal metric to quantify the "typicality" of a single sample.

This paper introduces Pseudo Density, a model-agnostic metric that estimates how common or rare a generated image is relative to the real data distribution. By leveraging this metric, researchers can precisely navigate the fidelity-diversity trade-off through individual sample manipulation, inference-time sampling, or efficient model fine-tuning.

Comparison of generated samples across the pseudo density spectrum, showing lower density (diverse/rare) vs. higher density (high-fidelity/common) images.

Methodology: The Pseudo Density Framework

The core of this approach is a three-step pipeline designed to estimate and then predict the density of samples in a high-dimensional feature space.

  1. Feature Extraction: Real images are processed through a pre-trained feature extractor (e.g., a Vision Transformer) to obtain representative embeddings.
  2. Density Estimation: For each real image, density is calculated based on its $K$-nearest neighbors in the feature space. Proximity to many neighbors indicates high density (common features), while isolation indicates low density (rare features).
  3. Predictor Training: To avoid the computational cost of nearest-neighbor searches during generation, a small multi-layer perceptron (MLP)—the Pseudo Density Predictor—is trained to map image features directly to these estimated density values.
Overview of the Pseudo Density pipeline: (a) estimating real distribution density, (b) training the density predictor, and (c) using the predictor for generated samples.

Applications for Model Control

With a differentiable density predictor, the authors propose three mechanisms for controlling generative output:

  • Per-sample Perturbation: Using Projected Gradient Descent (PGD), the latent code of a generated image can be nudged to increase its pseudo density (enhancing realism) or decrease it (enhancing uniqueness).
  • Importance Sampling: During inference, rejection sampling is employed to filter generated images, only accepting those that meet a specific density threshold to bias the output toward fidelity or diversity.
  • Fine-tuning: Pre-trained models can be quickly fine-tuned on a weighted version of the dataset, biased by pseudo density, to permanently shift the model's output distribution.

Experimental Evaluation

The framework was evaluated on high-resolution benchmarks including FFHQ (faces), LSUN-Church, and LSUN-Bedroom across multiple architectures like StyleGAN2/3 and diffusion models (IDDPM, ADM).

Key findings include:

  • Pareto Frontier Improvement: Importance sampling achieved a superior trade-off between Precision (fidelity) and Recall (diversity) compared to traditional truncation methods.
  • FID Optimization: Fine-tuning with pseudo density often improved the Fréchet Inception Distance (FID), suggesting that the method helps models find a more optimal balance than their original training.
  • Visual Realism: High-density samples typically exhibit cleaner backgrounds and more standard features, while low-density samples capture rarer, more complex details.

Conclusion

Pseudo density provides a robust, model-agnostic tool for controlling the output of deep generative models. By making the typicality of a sample differentiable, it enables both fine-grained editing and global model shifts. Future work may extend this framework to conditional generation tasks, such as text-to-image synthesis, and explore the impact of different feature extractor biases on density estimation.

Summary updated

BibTeX
@article{li2024controlling,
  author = {Shuangqi Li and Chen Liu and Tong Zhang and Hieu Le and Sabine Susstrunk and Mathieu Salzmann},
  title = {{Controlling the Fidelity and Diversity of Deep Generative Models via Pseudo Density}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=8Vk1Bmg3sY},
}
Figure