Benchmarking Counterfactual Image Generation

Thomas Melistas, Nikos Spyrou, Nefeli Gkouti, Pedro Sanchez, Athanasios Vlontzos, Yannis Panagakis, Giorgos Papanastasiou, Sotirios A. Tsaftaris · DOI

TL;DR

This paper introduces a comprehensive framework and benchmark for evaluating counterfactual image generation, a crucial but complex area of generative AI. By standardizing evaluation across various models, datasets, and causal graphs, they demonstrate that Hierarchical VAEs (HVAEs) generally outperform other methods in generating realistic and causally consistent edited images.

What Problem Does This Paper Address?

Generative AI has made image editing incredibly accessible, but simply changing pixels isn't enough for realistic and meaningful edits, especially in domains like medical imaging. Edits need to respect the underlying "causal relationships" – how different attributes in an image influence each other. For instance, changing a person's gender shouldn't result in them still having a beard if the causal model dictates otherwise. This is the realm of "counterfactual image generation." The challenge is that evaluating these counterfactuals is hard: there are no ground truth images to compare against, and we need to ensure the edits are both visually plausible and adhere to these causal rules. While methods exist, a unified and rigorous comparison framework has been missing, hindering progress in the field.

Methods

The authors tackle this by creating a standardized benchmarking framework. They focus on Structural Causal Models (SCMs) to explicitly define the causal relationships within datasets. Their evaluation framework incorporates several key components:

  • Abduction-Action-Prediction Paradigm: This is the core inference strategy.
  • Abduction: Inferring the "exogenous noise" (unobserved factors) that led to the observed factual image.
  • Action: Modifying the causal model to reflect the desired intervention (e.g., changing gender).
  • Prediction: Generating the counterfactual image based on the modified model and inferred noise.
  • Model Families: They evaluate three main types of generative models that can implement invertible mechanisms required for this process:
  • Conditional Normalizing Flows: Explicitly invertible, good for attribute manipulation.
  • Conditional VAEs/HVAEs: Amortized and explicit, suitable for high-dimensional data like images. HVAEs, with their hierarchical structure, are particularly highlighted.
  • Conditional GANs: Amortized and implicit, using adversarial training.
  • Evaluation Metrics: A suite of metrics is used to assess different aspects of counterfactual generation:
  • Composition: How well the model reproduces the original image when no intervention is applied (null-intervention).
  • Effectiveness: How successfully the intervention changes the intended attribute.
  • Realism: The visual quality and similarity of the generated counterfactual to real images (using FID).
  • Minimality: How much the counterfactual image deviates from the factual image, ideally only changing the intervened attribute (using CLD).

Datasets

The paper uses a combination of synthetic and real-world datasets:

  • MorphoMNIST: A synthetic dataset based on MNIST, where interventions on thickness affect both intensity and image structure.
  • CelebA: A dataset of celebrity faces, used with both a simple and a more complex causal graph to test attribute relationships (e.g., age, gender, beard, baldness, smile, eyeglasses).
  • ADNI: A dataset of brain MRI scans, used to generate counterfactuals for medical imaging applications (e.g., brain volume, ventricular volume, slice).

They also expand existing models to these datasets and novel causal graphs, demonstrating the framework's flexibility.

Key Insights and Ideas

  • HVAEs Shine: Hierarchical VAEs consistently outperform other models across most datasets and metrics, particularly in preserving image realism and effectively implementing causal interventions. Their hierarchical latent structure seems key to learning and maintaining complex causal relationships.
  • Causality is Crucial for Realism: Simply editing images without considering causal relationships leads to unrealistic and potentially misleading results, as illustrated in Figure 1.
  • Benchmarking is Essential: The lack of a standardized evaluation framework has been a bottleneck. This paper provides a much-needed unified approach, enabling fair comparisons and accelerating research.
  • Model Complexity Matters: While simpler models like VAEs struggle with complex causal graphs and higher resolutions, HVAEs show better adaptability. GANs can produce realistic images but often lack minimality.
  • Diffusion Models Need Adaptation: While diffusion models are powerful for image editing, adapting them for complex, multi-variable causal counterfactual generation requires significant methodological advancements.

Key Results

  • HVAE Superiority: HVAEs consistently achieved better scores in composition, effectiveness, and realism across MorphoMNIST, CelebA (simple and complex), and ADNI datasets. For example, on ADNI, HVAE showed significantly lower MAE for brain volume and ventricular volume interventions compared to VAE and GAN.
  • Composition: HVAEs demonstrated superior composition, meaning they could perform multiple null-interventions (reconstructions) without significant degradation of the original image, especially on complex datasets.
  • Effectiveness: HVAEs were generally more effective at changing the intended attribute while leaving others untouched, as shown by higher F1 scores and lower MAE in various intervention scenarios.
  • Realism (FID): HVAE generally produced the most realistic counterfactuals, closely matching the distribution of real images.
  • Minimality (CLD): HVAE also performed well in minimality, indicating that counterfactuals changed only the intended attributes.
  • GANs: While GANs could generate realistic images, they often struggled with minimality and preserving factual details, especially on complex datasets.
  • Diffusion Models: Their adapted diffusion model showed mixed results, performing well on composition for simple cases but deteriorating with more cycles and complex graphs.

Limitations and Future Work

  • Scalability: The current framework and models struggle to scale to higher resolution datasets (e.g., CelebAHQ at 256x256) and more complex causal graphs. This is attributed to the difficulty in accurately influencing model outputs in pixel space with gradients from classifiers.
  • Model-Dependent Metrics: Evaluating effectiveness relies on training anti-causal predictors, which themselves require careful training and can scale with graph complexity.
  • Diffusion Model Adaptation: The authors note that adapting diffusion models for multi-variable SCMs is an ongoing challenge, requiring new methods beyond simple extensions.
  • Future Directions: The authors suggest extending the benchmark to include other methods like deep twin networks and backtracking counterfactuals. They also aim to explore SCM-conditioning for diffusion models and encourage community contributions to their open-source Python package for further expansion.

Summary updated

BibTeX
@inproceedings{melistas2024benchmarking,
  author = {Thomas Melistas and Nikos Spyrou and Nefeli Gkouti and Pedro Sanchez and Athanasios Vlontzos and Yannis Panagakis and Giorgos Papanastasiou and Sotirios A. Tsaftaris},
  title = {{Benchmarking Counterfactual Image Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=z7mefYLjhd},
}
Figure