Counterfactual Image Editing

Yushu Pan, Elias Bareinboim

Introduction

Current AI image editing tools often conflate correlation with causation. For instance, prompting a model to age a person's face might inadvertently alter their gender due to biases in the training data (e.g., a dataset skewed towards older men and younger women). Standard generative models, such as GANs or Diffusion models, capture statistical correlations rather than true causal relationships. In reality, features are causally linked: age causes gray hair, but age does not cause gender.

Existing editing methods struggle with these nuances, either changing features that should remain constant due to spurious correlations or failing to update features that should change as a downstream effect of an intervention. This paper formalizes image editing as a causal inference problem, aiming to ground generative AI in the formal "Ladder of Causation" to ensure edits are realistic and logically sound.

Theoretical Framework: Augmented Structural Causal Models

The authors introduce Augmented Structural Causal Models (ASCMs) to bridge the gap between structural causal models (SCMs) and deep generative AI. This framework models image generation as a two-stage process:

  1. Causal Interaction: High-level generative factors (like age or gender) interact according to a causal graph.
  2. Pixel Mapping: These factors, combined with unobserved noise (representing specific, idiosyncratic details like wrinkle patterns), are mapped to the pixel space.

A crucial assumption in this framework is that high-level labels are "invertible"—meaning they can be accurately extracted back from the generated images.

Fundamental Impossibility Results

A major theoretical contribution of the paper is proving that "perfect" counterfactual editing is theoretically impossible from standard independent and identically distributed (i.i.d.) image samples and labels alone. The authors demonstrate mathematically that even when the causal graph between latent factors is known, one cannot always uniquely identify the exact counterfactual image distribution. No absolute guarantees regarding the output of the generative model can be provided under these standard conditions.

Ctf-Consistent Estimators and ANCM

To overcome this impossibility, the authors propose a practical relaxation. They define a "care set" of features that a user explicitly wishes to preserve or change. An estimator is deemed ctf-consistent if its output falls within mathematically derived optimal bounds of what is causally possible, even if the single "true" counterfactual image is unidentifiable.

Based on this theory, they develop the Augmented Neural Causal Model (ANCM). ANCM utilizes a VAE-like architecture to encode images into a latent space constrained by a specific causal diagram. This structure allows interventions (edits) to propagate correctly through the causal graph, updating dependent variables while leaving independent ones untouched.

Experimental Validation

The approach was evaluated on two primary datasets to test both theoretical bounds and qualitative performance:

  • Colored MNIST with Bars: A synthetic dataset where digit type, color, and the presence of a blue bar are causally linked. This allowed for precise testing against known ground-truth causal bounds.
  • CelebA-HQ: A high-resolution dataset of celebrity faces used to test complex, correlated attributes like Age, Gender, Gray Hair, Smiling, and Open Mouth.

Key Results and Insights

  • Causal Consistency: In the synthetic MNIST tasks, ANCM was the only model to remain within theoretical optimal bounds for feature changes. Baselines like CVAE and DEAR frequently produced causally impossible images given the data distribution.
  • Preserving Identity: In CelebA-HQ experiments, ANCM successfully prevented identity loss. When aging a female face, baseline models often shifted the gender to male due to dataset bias. ANCM, guided by the causal graph, recognized that age does not cause gender, thereby preserving the subject's identity.
  • Cascading Interventions: The model correctly updated downstream "child" variables when a "parent" variable was intervened upon. For example, changing a subject's age correctly influenced the presence of gray hair, while opening a person's mouth didn't artificially force a smile—a common failure in correlational models.

Limitations and Future Work

While ANCM provides a rigorous framework for causally sound image editing, it has limitations. The method relies on a pre-defined causal graph, which may not be fully known in complex real-world scenarios. Furthermore, the invertibility assumption—that labels can be perfectly extracted from images—may fail for low-quality or highly ambiguous data. Finally, scaling these causal constraints to highly complex scenes with hundreds of interacting objects remains a significant challenge for future research.

Summary updated

BibTeX
@inproceedings{pan2024counterfactual,
  author = {Yushu Pan and Elias Bareinboim},
  title = {{Counterfactual Image Editing}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=OXzkw7vFIO},
}
Figure