Manuscript Offprint

arXiv:2610.23577

CLEAR: Cooperative Latent Flow for Visual Counterfactual Explanations with Accurate Region Preservation

Yan Zeng, Changlu Guo, Oskar Kristoffersen, Anders Nymark Christensen, Morten Rieger Hannemose, Anders Bjorholm Dahl

Abstract

Visual counterfactual explanations (VCEs) should alter a classifier's prediction while remaining realistic and preserving decision-irrelevant content. Image-space methods provide high-quality counterfactuals but are computationally costly, whereas latent-space methods are more efficient but often less faithful. We identify two sources responsible for this gap. First, latent generation recovers a natural sample from a perturbed representation, whereas classifier guidance pushes it toward a target class, so their update directions may oppose. Second, VAE reconstruction can alter regions that should remain unchanged. We introduce CLEAR, a latent Flow Matching framework for VCEs. CLEAR uses Flow Matching's explicit instantaneous velocity as a reference for the generative direction to decompose classifier guidance into cooperative and conflicting components. It preserves the cooperative component and adaptively attenuates only the conflicting one according to conflict strength. We further analyze conflict frequency and strength throughout generation to reveal how classifier guidance interacts with the generative process. CLEAR also dynamically identifies editable regions, constrains latent modifications, and directly preserves factual content outside them to reduce VAE-induced changes. Across five bidirectional tasks on two datasets, CLEAR retains latent-space efficiency while achieving counterfactual quality comparable to or better than strong image-space baselines, with a 2.5×2.5\times speedup over the strongest baseline. Project page: https://yan-zen9.github.io/CLEAR/

1. Introduction

Visual counterfactual explanations (VCEs) address a question: what meaningful change to an input image would alter a classifier's prediction? [16, 42] Unlike attribution

Factual Image

No Smile → Smile

Additive Guidance

Hard Projection

CLEAR

Figure

Source: No Smile

Target Prob.: 0.96

Target Prob.: 0.53

Target Prob.: 0.99

Figure 1. Motivation for Cooperative Flow Guidance. Additive guidance may cause excessive editing, while hard projection can lead to insufficient editing. CLEAR adaptively regulates conflicting guidance to produce a natural and effective counterfactual.

methods that highlight potentially important regions, VCEs show the visual changes needed to produce an alternative prediction [13, 16, 39, 40]. A reliable counterfactual should change the classifier prediction while remaining realistic and preserving content unrelated to the target decision [25, 34, 45]. Diffusion models have improved VCE quality by keeping counterfactuals close to the natural image distribution [1, 2, 24, 25]. However, image-space methods repeatedly perform generation and classifier guidance in high-dimensional pixel space, leading to substantial computational and memory costs [17, 46]. Latent generation provides an efficient alternative by operating on compact representations [8, 30, 33, 38], but often at the cost of counterfactual fidelity. The challenge is to retain latent-space VCE efficiency while approaching the fidelity of image-space methods.

One key challenge is aligning classifier guidance with the generative process. Latent generation seeks to recover a natural sample from a perturbed representation, whereas classifier guidance pushes the sample toward a target class. During counterfactual generation, these objectives can produce opposing update directions. Importantly, such conflict does not mean that the entire classifier guidance is harmful:

∗^{*}Changlu and Oskar contributed equally to this work.

a single signal can contain both cooperative and conflicting components. Treating the whole guidance uniformly may either retain harmful conflict or discard useful information. CLEAR uses the explicit instantaneous velocity provided by Flow Matching [31] as a reference for the current generative direction. Unlike the sampler-dependent updates in DDPMs [21], this explicit direction allows CLEAR to decompose the components of classifier guidance with respect to the current generative flow. CLEAR preserves the cooperative component and adaptively attenuates only the conflicting component according to conflict strength. As shown in Fig. 1, this avoids both excessive editing from fully retained conflicting guidance, and insufficient modification from removing it entirely. We further analyze directional conflicts throughout generation by examining their frequency, strength, and effect on the final counterfactuals, showing how classifier guidance interacts with the generative process.

A second challenge comes from VAE reconstruction, which can modify regions that should remain unchanged [33, 37]. CLEAR therefore identifies editable regions dynamically and maps them to latent resolution to constrain classifier-guided modifications throughout generation. Outside this support, the latent trajectory follows the original flow, and the final content outside the editable support is directly preserved in image space, preventing VAE reconstruction and latent editing leakage from affecting pixels outside the estimated support. Our main contributions are:

• We propose Cooperative Flow Guidance, which uses the explicit velocity field of Flow Matching for component-wise, conflict-aware regulation of classifier guidance during counterfactual generation.

• We systematically analyze directional conflicts during counterfactual generation to clarify the interaction between classifier guidance and the generative process.

• We introduce Adaptive Support Preservation (ASP), which dynamically localizes editable regions and preserves decision-irrelevant factual content across latent and image spaces.

• On two CelebA-HQ attributes and three ImageNet class pairs, CLEAR improves FID and sFID over the evaluated latent-space baselines; the CelebA-HQ Smile benchmark demonstrates a favorable quality–efficiency trade-off against image-space methods.

References (46)

  • Diffusion visual counterfactual explanations
  • Dig-in: Diffusion guidance for investigating networks – uncovering classifier differences, neuron visualisations and visual counterfactual explanations
  • Universal guidance for diffusion models
  • VGGFace2: A dataset for recognising faces across pose and age
  • LeapFactual: Reliable visual counterfactual explanation using conditional flow matching
  • Exploring simple Siamese representation learning
  • Looking in the mirror: A faithful counterfactual explanation method for interpreting deep image classification models
  • Gifsplanation via latent shift: A simple autoencoder approach to counterfactual generation for chest x-rays
  • Flow matching in latent space (opens arXiv in a new tab)
  • ImageNet: A large-scale hierarchical image database
  • Diffusion models beat GANs on image synthesis
  • On the guidance of flow matching
  • Interpretable explanations of black boxes by meaningful perturbation
  • $C^{2}FG$: Control classifier-free guidance via score discrepancy analysis
  • Towards practical plug-and-play diffusion models
  • Counterfactual visual explanations
  • MaskDiME: Adaptive masked diffusion for precise and efficient visual counterfactual explanations
  • Deep residual learning for image recognition
  • GANs trained by a two time-scale update rule converge to a local Nash equilibrium
  • Classifier-Free Diffusion Guidance
  • Denoising diffusion probabilistic models
  • Densely connected convolutional networks
  • STEEX: Steering counterfactual explanations with semantics
  • Diffusion models for counterfactual explanations
  • Adversarial counterfactual visual explanations
  • Text-to-image models for counterfactual explanations: A black-box approach
  • Progressive growing of GANs for improved quality, stability, and variation (opens arXiv in a new tab)
  • Grounding counterfactual explanation of image classifiers to textual concept space
  • Tcfg: Tangential damping classifier-free guidance
  • Explaining in style: Training a gan to explain a classifier in stylespace
  • Flow matching for generative modeling
  • Deep learning face attributes in the wild
  • From visual explanations to counterfactual explanations with latent diffusion
  • Benchmarking counterfactual image generation
  • Generating images with sparse representations
  • Beyond trivial counterfactual explanations with diverse valuable explanations
  • High-resolution image synthesis with latent diffusion models
  • Latent diffusion counterfactual explanations
  • Grad-cam: Visual explanations from deep networks via gradient-based localization
  • Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps
  • Rethinking visual counterfactual explanations through region constraint
  • Counterfactual explanations without opening the black box: Automated decisions and the GDPR. Harvard Journal of Law & Technology, 31(2):841–887, 2017
  • End-to-end diffusion latent optimization improves classifier guidance
  • CFG-Ctrl: Control-based classifier-free diffusion guidance
  • Scout: Self-aware discriminant counterfactual explanations
  • Fast diffusion-based counterfactuals for shortcut removal and generation