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

WACV 2027

Accepted to WACV 2027 (Direct Round 2 submission)

Technical University of Denmark
*Equal contribution
Additive guidance causes excessive editing, hard projection causes insufficient editing, and CLEAR produces a natural smile

CLEAR adaptively regulates conflicting classifier guidance, avoiding both the excessive editing of additive guidance and the insufficient editing of hard projection.

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× speedup over the strongest baseline.

Method Overview

Starting from a partially noised factual latent, CLEAR evolves a single latent trajectory along a guided flow. At each step, the flow model provides the generative velocity and a one-step image estimate, from which the frozen target classifier produces both the classifier force and the current decision-relevant support. Cooperative Flow Guidance determines how the classifier force modifies the generative direction, while Adaptive Support Preservation determines where the modification is allowed.

Overview of the CLEAR framework

Overview of CLEAR. Repeating these coupled updates yields a counterfactual that concentrates changes within the evolving editable support while preserving decision-irrelevant factual content.

Cooperative Flow Guidance

Flow Matching predicts an explicit instantaneous velocity vt, which can be compared directly with the classifier force ut = −gt, unlike the sampler-dependent updates of DDPMs. CLEAR decomposes ut into components parallel and orthogonal to vt, and attenuates only the opposing parallel component, with a strength that grows with the degree of conflict. Cooperative guidance is therefore preserved, and only harmful conflict is suppressed.

From sampler-dependent denoising to cooperative flow guidance

From sampler-dependent denoising to cooperative flow guidance. (a) In DDPMs the update direction depends on the chosen sampler. (b) Flow Matching directly predicts the velocity vt, an explicit generative direction. (c) Under mild or severe conflict, CLEAR increasingly attenuates only the opposing component as the conflict strength grows.

Adaptive Support Preservation

CLEAR estimates the editable support with target-class Grad-CAM on the classifier view, keeps the top salient pixels, extracts the largest connected component and dilates it. The support is refreshed at every step, so it adapts as the counterfactual evolves. Average-pooling it to the latent grid yields a soft gate: classifier-driven updates act inside the support, while the rest of the latent follows the original flow. Finally, the factual pixels outside the final support are copied back, so that VAE reconstruction cannot alter them.

Efficiency

On CelebA-HQ Smile, CLEAR achieves the lowest runtime and FID among the compared methods while keeping a low peak GPU memory footprint, with 2.5× and 58.1× speedups over MaskDiME and DiME, respectively. It is also substantially faster than the latent baseline LDCE-txt, with a clearly lower FID.

Runtime, FID and peak GPU memory comparison on CelebA-HQ Smile

1,000 images at 256×256 resolution with a batch size of 3. Runtime and peak GPU memory measure counterfactual inference only. † denotes a latent-space method.

Quantitative Results

CelebA-HQ

CLEAR achieves the best FID and sFID on both Smile and Age, while maintaining near-perfect validity and strong identity preservation. Compared with existing latent VCE methods, CLEAR substantially improves realism and approaches or surpasses strong image-space baselines, narrowing the fidelity gap between latent- and image-space counterfactual generation while avoiding excessive non-target changes.

MethodSmileAge
FID ↓sFID ↓FVA ↑FS ↑MNAC ↓CD ↓COUT ↑FR (%) ↑FID ↓sFID ↓FVA ↑FS ↑MNAC ↓CD ↓COUT ↑FR (%) ↑
DiVE107.0–35.7–7.41–––107.5–32.3–6.76–––
STEEX21.9–97.6–5.27–––26.8–96.0–5.63–––
DiME18.127.796.70.672.631.820.6597.018.727.895.00.662.104.290.5697.0
ACE ℓ13.2120.2100.00.891.562.610.5595.05.3121.799.60.811.535.400.4095.0
ACE ℓ26.9322.0100.00.841.872.210.6095.016.428.299.60.771.924.210.5395.0
TiME10.9823.896.60.792.972.320.6397.120.932.979.30.634.194.290.3189.9
RCSB3.0420.0100.00.941.223.220.8398.94.9227.3100.00.961.475.160.8099.4
MaskDiME2.5118.1100.00.941.412.670.6999.44.4319.4100.00.881.824.670.6399.6
LDCE-txt†13.625.899.10.762.441.680.34–14.225.698.00.732.124.020.33–
ECED†7.5624.9100.00.901.325.080.84–12.431.6100.00.960.844.930.74–
CLEAR†2.1817.4100.00.941.302.280.6599.64.1119.0100.00.911.384.940.67100.0

Quantitative comparison on CelebA-HQ across the Smile and Age tasks. Methods marked with † operate in latent space. Best and second-best results are highlighted in bold and underline, respectively.

ImageNet

CLEAR consistently outperforms existing latent-space methods in FID and sFID across all three semantic class pairs, while remaining competitive with the strongest image-space baselines. At the same time, CLEAR achieves the best or tied-best S3 with near-perfect flip rates, so its quality–efficiency advantage extends beyond localized facial edits to challenging global semantic transformations.

MethodSorrel – ZebraPersian Cat – Egyptian CatCougar – Cheetah
FID ↓sFID ↓S3 ↑COUT ↑FR (%) ↑FID ↓sFID ↓S3 ↑COUT ↑FR (%) ↑FID ↓sFID ↓S3 ↑COUT ↑FR (%) ↑
DiME222.9243.20.19−0.310.0322.8352.10.44−0.050.0268.2292.00.11−0.160.0
ACE ℓ184.5122.70.92−0.4547.093.6156.70.850.2585.070.2100.50.910.0277.0
ACE ℓ267.798.40.90−0.2581.0107.3160.40.780.3497.074.1102.50.880.1295.0
FastDiME96.5103.50.22−0.4414.0193.6207.10.100.0120.0133.0141.10.12−0.1118.0
DVCE33.143.90.62−0.2157.846.659.20.590.6098.546.954.10.700.4999.0
RCSB8.016.20.880.7494.723.040.00.870.92100.017.226.60.920.92100.0
MaskDiME32.539.70.940.8599.736.250.10.870.89100.037.446.30.930.92100.0
LDCE-cls†84.2107.20.78−0.0688.0102.7140.70.630.5299.071.091.80.620.51100.0
LDCE-txt†82.4107.20.71−0.2181.0121.7162.40.610.5699.091.2117.00.590.3498.0
ECED-v†33.045.20.950.7798.027.453.50.980.85100.023.337.30.950.8399.5
ECED-r†63.197.80.860.6898.544.371.20.940.81100.047.076.60.960.82100.0
CLEAR†24.331.30.960.7799.926.742.10.980.82100.021.635.50.960.84100.0

Quantitative comparison on ImageNet across three semantic class pairs. Methods marked with † operate in latent space. Best and second-best results are highlighted in bold and underline, respectively.

Visual Results

CLEAR produces localized edits with strong identity preservation on CelebA-HQ, and handles challenging global semantic transformations on ImageNet.

CelebA-HQ

Qualitative comparison on CelebA-HQ between the factual image, MaskDiME and CLEAR

Qualitative comparison on CelebA-HQ using DenseNet-121. From left to right: the factual image and counterfactual images generated by MaskDiME and CLEAR.

ImageNet

Qualitative results on ImageNet for three bidirectional class pairs

Qualitative results on ImageNet using ResNet-50. Each pair shows a factual image and the corresponding counterfactual generated by CLEAR for the paired target class.

Directional Conflict Analysis

Directional conflict occurs frequently across all five bidirectional tasks and becomes more common toward the end of generation, which is counter-intuitive since the classifier force is expected to align better with the generative direction as target semantics emerge. Conflict strength follows task-dependent dynamics: ImageNet transformations show strong early conflicts that decrease rapidly, whereas CelebA-HQ edits start weaker, peak at intermediate stages and then decline. Conflict should therefore not be treated as a binary event, and its degree matters. Hard Projection and Additive Guidance retain 0% and 100% of the conflicting component, whereas CLEAR adaptively retains 83.3–88.8% across the five tasks.

Conflict frequency, conflict strength and retained conflicting component across five tasks

Directional conflict analysis during generation. (a) Conflict frequency across Flow Matching timesteps. (b) Conflict strength, measured by ‖ut∥‖2 / ‖vt‖2. (c) Percentage of the conflicting component retained after Cooperative Flow Guidance.

The conflict regime also shapes the final counterfactual. When conflicts are weak, even a high conflict frequency leads to limited differences between guidance strategies. Low-frequency but strong conflicts are already enough to produce noticeable differences: Additive Guidance may cause excessive modification, whereas Hard Projection may over-suppress useful classifier guidance. When both frequency and strength are high, the differences are most pronounced, and CLEAR achieves a better balance between target modification and visual naturalness.

Qualitative results under different conflict regimes on CelebA-HQ Smile

Qualitative results under different conflict regimes. Rows show examples with different combinations of conflict frequency and strength.

Additional qualitative results under different conflict regimes on CelebA-HQ Age and ImageNet

Additional results (supplementary). CelebA-HQ Age and ImageNet show the same consistent behavior across conflict settings.

Ablation Study

We evaluate the main components of CLEAR on CelebA-HQ Smile. For Cooperative Flow Guidance, Additive Guidance disables conflict-aware attenuation (βt = 0), while Hard Projection completely removes the opposing component whenever it exists. Fully retaining conflicting guidance degrades realism and non-target preservation, while removing it entirely reduces counterfactual validity. For Adaptive Support Preservation, removing any of the three components degrades the overall performance.

VariantFID ↓MNAC ↓COUT ↑FR (%) ↑MSE ↓
CLEAR2.181.300.6599.60.000
Cooperative guidance
Additive Guidance4.472.160.7199.70.000
Hard Projection3.661.630.6495.60.000
Adaptive Support Preservation
Fixed Mask3.401.570.6193.70.000
W/o Masked View9.743.070.7399.60.000
W/o Latent Mask6.422.480.5892.80.000
W/o Pixel Reuse3.521.610.6099.60.011

MSE is measured outside each variant's final editable support and is zero by construction for variants using factual-pixel composition.

Hyperparameter Sensitivity

We vary one parameter at a time from the default configuration (τ = 0.5, ts = 0.6, N = 20, s = 8, ρ = 5%) on CelebA-HQ Smile. The results show substantial trade-offs between counterfactual validity, realism, and preservation, so parameter selection matters. This single-task analysis does not establish robustness across datasets.

SettingFID ↓MNAC ↓COUT ↑FR (%) ↑
Default2.181.300.6599.6
Conflict sensitivity
τ = 0.252.541.330.5995.2
τ = 1.04.281.710.6899.7
Starting-time sensitivity
ts = 0.45.423.270.7499.9
ts = 0.83.401.420.6586.4
Sampling-step sensitivity
N = 102.981.350.5790.1
N = 403.661.510.6899.5
Guidance-scale sensitivity
s = 42.211.300.4493.5
s = 125.823.400.7299.7
Support-ratio sensitivity
ρ = 3%2.121.290.4288.0
ρ = 8%2.631.480.6799.6

Hyperparameter sensitivity on CelebA-HQ Smile (supplementary). A smaller τ or s, a later ts, fewer steps, or a smaller ρ lower the flip rate, whereas a larger τ or s and an earlier ts raise validity at the cost of FID and MNAC. The default balances validity, realism, and preservation.

Region Preservation

The editable support concentrates changes in target-relevant regions while preserving the remaining factual content. Since CLEAR reuses the factual pixels outside the final support, the error in these regions is zero by construction. This verifies the composition operation, but it does not independently validate support accuracy or continuity at the composition boundary.

Factual image, saliency map, counterfactual and absolute difference map

Visualization of localized counterfactual editing (supplementary).

Factual image, CLEAR counterfactual and pixel-wise difference map for four tasks

Exact preservation with Adaptive Support Preservation (supplementary). From left to right: factual image, CLEAR counterfactual, and pixel-wise difference map. Pixels outside the editable support remain unchanged.

BibTeX

Coming soon.