CoLa-DCE – Concept-guided Latent Diffusion Counterfactual Explanations

## Abstract

Abstract Recent advancements in generative AI have introduced novel prospects and practical implementations. Especially diffusion models show their strength in generating diverse and, at the same time, realistic features, positioning them well for generating counterfactual explanations for computer vision models. Answering “what if” questions of what needs to change to make an image classifier change its prediction, counterfactual explanations align well with human understanding and consequently help in making model behavior more comprehensible.
Current methods succeed in generating authentic counterfactuals, but lack transparency as feature changes are not directly perceivable.
To address this limitation, we introduce Concept-guided Latent Diffusion Counterfactual Explanations (CoLa-DCE) . CoLa-DCE generates concept-guided counterfactuals for any classifier with a high degree of control regarding concept selection and spatial conditioning.
The counterfactuals comprise an increased granularity through minimal feature changes.
The reference feature visualization ensures better comprehensibility, while the feature localization provides increased transparency of “where” changed “what” .
We demonstrate the advantages of our approach in minimality and comprehensibility across multiple image classification models and datasets and provide insights into how our CoLa-DCE explanations help comprehend model errors like misclassification cases.

## 1 Introduction

In the field of eXplainable Artificial Intelligence (xAI), counterfactual explanations have gained new interest with recent advances in generative models [, , ].
The usage of counterfactual explanations, answering what would need to change to induce a different outcome, is motivated by research in psychology and the social sciences [, ], connecting counterfactuals with human reasoning.
While current development efforts in xAI often focus on technical feasibility rather than on the alignment with human understanding of a Deep Neural Network (DNN) model [], counterfactuals provide an opportunity for the user to contemplate alternative model outputs.
In the image domain, a human inspector can directly compare an original image with its counterfactual to derive which differences induce a prediction change in the model under test.
Key requirements for the counterfactual to be deemed a plausible alternative are the consistency with the user’s beliefs, as being realistic, and a minimal effort for changing towards the counterfactual [].
The minimality constraint expresses a more likely transition due to a smaller image alteration, while additionally, the decision boundary between both classes can be better estimated.

Specifically for image manipulations, diffusion models have proven to be advantageous.
Diffusion models [, , , ] are capable of generating realistic high-resolution images with diverse features within the data distribution, which promotes them as an ideal tool for generating counterfactual images [, , ].
While previous works for diffusion-based image counterfactuals find optimizations with regard to all features in an image or a local area inside an image, it is often unclear which features precisely change toward the counterfactual and how they relate to the model prediction.
Especially with many slight feature changes in an image, tracking the changes and comprehending the decision boundary based on these features becomes unfeasible.
Considering the example of the “hen” in Figure 1, every part of the animal, e.g., head, feathers, and color, as well as background features like the flooring, could yield significant changes towards the counterfactual class without being recognizable to the user.
Regarding the desire for minimality in image alteration, we further point out the yet missing strategy of defining minimality more semantically in the number of semantic features rather than pixels changed.

With our Concept-guided Latent Diffusion Counterfactual Explanations (CoLa-DCE), we solve both problems: We guide the counterfactual generation with a restricted number of semantic concepts, further enabling a high level of control by concept selection.
We additionally include feature visualization capabilities, allowing for direct comprehensibility of features that represent the difference between the original and the counterfactual class.
Hereby, CoLa-DCE provides semantic as well as spatial guidance and visualization, simultaneously enabling control and better transparency.
Our contributions are:

- 1.
We introduce CoLa-DCE for the diffusion-based generation of counterfactuals using a semantic concept-guidance. We show how local counterfactual targets and concept-guided feature changes derived from the classifier’s perception increase the quality of the counterfactuals.
- 2.
We extend our concept guidance with spatial conditioning and reveal the semantic and localized image changes with transferring methods for concept visualization and concept localization maps, resulting in more transparent and more comprehensible counterfactuals highlighting the image changes.
- 3.
We show how our CoLa-DCE samples help in model debugging by making cases of misclassification more understandable. The semantic concept visualization provides strategies for feature-based model and/or dataset adaptations.

The source code will be published at [github.com/continental/concept-counterfactuals](github.com/continental/concept-counterfactuals).

## 2 Background

Diffusion models [] evolve from the idea of gradually adding small amounts of Gaussian noise to an image in a forward process, which can then be gradually reversed by learning the respective backward process.
Given scalar noise scales ${\alpha_{t}}_{t=1}^{T}$ with $T$ denoting the number of time steps and an input image $x_{0}$, the noisy image representations $x_{t}$ for the forward diffusion process can be computed with:

$$ $x_{t}=\sqrt{\alpha_{t}}x_{0}+\sqrt{1-\alpha_{t}}\epsilon_{t},\quad\text{where} \quad\epsilon_{t}\in\mathcal{N}(0,\mathbf{I}).$ (1) $$

Based on the current noise sample $x_{t}$ and time step $t$, a modified U-Net [] can be used for estimating the noise $\hat{\epsilon}_{t}$, which was added at that time step:

$$ $\epsilon_{\theta}(x_{t},t)\approx\hat{\epsilon}_{t}=\frac{x_{t}-\sqrt{\alpha_{ t}}x_{0}}{\sqrt{1-\alpha_{t}}}.$ (2) $$

The original image $x_{0}$ can be approximately predicted, when rewriting Equation 2 as:

$$ $\hat{x}_{0}\approx\frac{x_{t}-\sqrt{1-\alpha_{t}}\epsilon_{\theta}(x_{t},t)}{ \sqrt{\alpha_{t}}}.$ (3) $$

Sampling methods like the DDIM sampling [] speed up the image generation by estimating multiple timesteps and can be used to sample the next less-noisy representation $x_{t-1}$:

$$ $x_{t-1}=\sqrt{\alpha_{t-1}}\frac{x_{t}-\sqrt{1-\alpha_{t}}\hat{\epsilon}_{t}}{ \sqrt{\alpha_{t}}}+\sqrt{1-\alpha_{t-1}-\sigma_{t}^{2}}\hat{\epsilon}_{t}+ \sigma_{t}\epsilon_{t}.$ (4) $$

Latent diffusion models [] decrease the dimensionality of the input by incorporating an additional encoder-decoder architecture.
The encoder derives a dense representation of the data point so that the diffusion process can be applied in the dense feature space.
The generated output is decoded into an observable image afterward.

For guiding the image generation with an external classifier, [] introduces classifier guidance with a scaling factor influencing the trade-off between the accuracy and diversity of generated images.
Classifier-free diffusion guidance [] separates the conditioning into an unconditional part and a conditional part, where the difference between both parts can be used as an implicit classifier score:

$$ $\nabla_{x}\log p_{\eta}(x|c)=\nabla_{x}\log p(x)+\eta\nabla_{x}\log p(c|x).$ (5) $$

This gradient-based scoring for guiding the diffusion process by both external and implicit classifiers can be utilized to constitute the counterfactual generation by shaping the gradient.

## 3 Related Work

### 3.1 Counterfactual Generation

A number of methods attempt to transfer counterfactual explanations to the image domain.
Counterfactual Visual Explanations (CVE) [] replaces feature regions in an image with matching image patches from a distractor image of the counterfactual class.
Other works [, ] directly optimize an input image by minimizing a loss, shifting the classification towards the counterfactual class while keeping the image changes minimal.
SVCE [] yields further improvements to the optimization by combining the L1- and L2-norm to acquire a balance between non-sparse and too-sparse feature changes.
However, directly optimizing the image requires a robust classification model.

DiME [] introduces diffusion models for generating counterfactuals, where the classification model guides the diffusion process.
However, DiME is limited to robust classifiers explicitly trained on noisy images.
ACE [] is a two-step process consisting of computing pre-explanations and refining them.
A localization mask for the most probable feature change is computed before repainting the image by combining the generated counterfactual within the mask with the original image outside.

Diffusion Visual Counterfactual Explanations (DVCE) [] relaxes the constraint for the classifier to be robust by including an additional adversarially robust classifier.
Aligning the gradients of both models with a cone projection robustifies the diffusion guidance.
However, generated features might be induced by the robust classifier rather than the original classifier, decreasing the validity in explaining the original classifier.
Latent Diffusion Counterfactual Explanations (LDCE) [] overcomes the requirement of having a robust classifier by constructing a consensus mechanism for aligning the gradient of the external classifier with the gradient of the implicit classifier of the diffusion model directly. However, feature changes are hard to track due to the optimization on all features.

Although the previous works are able to generate realistic counterfactual images, the resulting counterfactuals lack transparency regarding which features have been changed and how the change is reflected in the parameters of the target model.
To our knowledge, the image domain has not considered a concept-based approach that guides feature changes on a semantic concept level and enforces minimality by restricting the number of feature changes.
Concept-based counterfactuals yield the opportunity to improve transparency and comprehensibility for the user while being semantically more similar to the original image.

### 3.2 Local Concept Attribution

Layer-wise Relevance Propagation (LRP) [] describes a local attribution method that backpropagates a modified gradient to assign pixel-wise importance scores for an input based on a selected target class.
Concept-wise Relevance Propagation (CRP) [] extends LRP to the concept space by defining the encoding of every single neuron or channel in the latent space as a concept.
During the attribution backward pass, a concept mask is applied, which filters the attribution for a single channel so that only the attribution for the selected channel is retained.
When inspecting the channel-constrained explanations for multiple samples, denoted as Relevance Maximization [], a semantic meaning describing a concept can be assigned to the channel.
Our approach utilizes the generalization of the latent space masking for a gradient manipulation and applies Relevance Maximization to visualize the determining concepts.

## 4 Concept-guided Latent Diffusion Counterfactual Explanations

Figure: Figure 2: A simplified overview of the model architecture for our CoLa-DCE approach, including the target selection (right) and the concept-conditioning for guiding the diffusion denoising (middle).
Refer to caption: x2.png

Our CoLa-DCE method consists of three main improvements to current diffusion-based image counterfactual methods.
In step 1, local sample-based targets are derived based on the model perception.
Step 2 consists of concept conditioning to guide the image adaptation using a selection of concepts, while step 3 adds spatial conditioning to the selected concepts.
Thus, concept and spatial conditioning selectively modify the classifier gradient before conditioning the diffusion generation process.

### 4.1 Local Counterfactual Targets

To select the counterfactual target class, we use the model’s perception of the respective data sample and compare it to the perception of a reference dataset $X^{\prime}$.The model perception can hereby be derived by either computing the activation of the model for each sample in a selected layer or by computing the intermediate attribution using a local xAI method like LRP [].
As the model perception of the data shall be represented, the class predictions of the model are used to determine class affiliation.

$$ $y_{c}=f(argmin_{x^{\prime}\in X^{\prime}}d(\kappa(x^{\prime}),\kappa(\hat{x})) \quad\text{and}\quad f(x^{\prime})\neq f(\hat{x}))$ (6) $$

For a new sample $\hat{x}\in\hat{X}$ that we want to generate a counterfactual for, we derive the model prediction and feature space encoding $\kappa(\hat{x})$ and compare it to the encodings of the reference dataset.
Hereby, based on the feature space encodings, the closest reference point with a differing class prediction is extracted, resembling the near miss approach [].
The counterfactual target $y_{c}$ is then defined as the predicted class of the reference point $x^{\prime}$.

Figure: Algorithm 1 CoLa-DCE algorithm for sample $x_{i}$ with $k$ concepts and class condition $c$

### 4.2 Concept Selection

For a selected counterfactual target class $y$, the gradient $\nabla_{x}p(x|y)$ of a sample $x$ can be extracted in each network layer.
For the selected layer $l$, the intermediate gradient is summed over the spatial dimensions to obtain a one-dimensional representation over the channels, which are expected to encode a particular concept each [].
Taking the absolute value of the summed gradients, the top-$k$ concepts with $k\in\mathcal{N}(1,K)$, and $K$ denoting the overall number of channels, are selected, which are per gradient most likely to induce a change towards the counterfactual class.
The concepts can be visualized using a feature visualization method like CRP [].

### 4.3 Concept Conditioning

Based on the LDCE [] algorithm, we apply an additional concept conditioning functionality concerning the selected concepts.
The conditions require precomputation and remain fixed during the counterfactual generation, as adapting the conditions to each single generation step leads to changing concepts in each step.

Instead of using the complete gradient of the external classifier $\nabla_{x}p(x|y)$ for target $y$, the conditioned gradient with regards to the selected concepts $\lambda_{1}$, …,$\lambda_{k}$ with binary constraints $\theta_{1}$, …, $\theta_{k}$ is computed. With the selected layer $l$ splitting the model into two parts $p(x|y)=h(g(x|y)|y)$, the conditioned gradient is computed as:

$$ $\displaystyle\nabla_{x}p(x|y,\theta_{1}...\theta_{k})$ $\displaystyle=\nabla_{x}(h(g(x))|y,\theta_{1}...\theta_{k})$ (7) $\displaystyle=\delta(\nabla_{g(x)}h,\theta_{1}...\theta_{k})\cdot\nabla_{x}g$ $\displaystyle\text{with}\quad\delta(\nabla_{g(x)}h,\theta_{1}...\theta_{k})_{j}$ $\displaystyle=\begin{cases}\nabla_{g(x)}h_{j},&\text{if }j\in\{\theta_{1},..., \theta_{k}\}\\ 0,&\text{otherwise}\end{cases}$ $$

with $\delta$ indicating binary masking the latent space gradient in the selected layer.
The masked latent gradient can be backpropagated to the input without further constraints.

### 4.4 Spatial Conditioning

While the introduced concept conditioning focuses on semantic features that need to change, the spatial dimensions in the feature layer of choice state where the selected features are most likely to change.
We assume that each feature should be only changed at a single location or that the gradient towards these features is approximately equal in equivalent locations.
Therefore, we add binary masking to the spatial dimensions similar to Equation 7 based on the gradient for the selected features, which sets gradients below a threshold $\eta$ to zero.
The binary mask can additionally be upscaled to the input scale like in Net2Vec [], yielding additional information about where a specific concept is expected to change towards the counterfactual.
The spatial conditioning minimizes the feature change by restricting it locally while contributing to comprehensibility by providing feature localization.

## 5 Results

We test our approach on the ImageNet [] validation dataset using multiple pre-trained models provided by Torchvision: a VGG16 [] with and without batch normalization, a ResNet18 [], and a ViT model [].
For deriving appropriate targets, 90% of the validation data is used as a reference dataset, while counterfactuals for the evaluation are generated on the remaining 1000 samples, including all ImageNet classes.
We inherit the parametrization parameters from LDCE [].
Showing the applicability to different datasets, additional counterfactuals for Oxford Pets [] and Flowers [] can be found in Appendix A.3.

As there exists no ground truth for counterfactual examples, a rough estimate regarding the quality can only be assessed via quantifying desired properties as the minimality and the accuracy.
We align our evaluation with [] and compute the FID score [] as well as the L1 and L2 norm between the original and counterfactual image to measure their semantic and pixel-based distance, denoting the minimality. The flip ratio (FR) determines the accuracy by measuring how often the classifier predicts the counterfactual class for the generated sample.

As an additional optimization measure, we suspend the concept conditioning for the last 50 generation steps of the diffusion process.
While coarse semantic features are expected to be generated within the first steps of the diffusion process, the last steps incorporate an image refinement, e.g., by completing and connecting edges.
When suspending the conditioning towards the end of the generation, visible semantic changes are not perceivable, but the image is classified more accurately.
This can also be seen in a consistent FID score and an improved flip ratio.

### 5.1 Selecting a local target results in improved counterfactuals

**Table 1: Quantitative comparison showing the effect of the target selection on the generated counterfactuals using the LDCE method in comparison to our CoLa-DCE method ($k$=20).**
| Model Setting |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Model | Method | Target | Layer | FID $\downarrow$ | L1 $\downarrow$ | Flip Ratio $\uparrow$ | Confidence $\uparrow$ |
| VGG16bn | LDCE | Base | - | 55.46 | 12458 | 0.851 | 0.81 |
| VGG16bn | LDCE | Act | feat.37 | 59.12 | 12456 | 0.936 | 0.89 |
| VGG16bn | LDCE | Attr | feat.37 | 45.56 | 12443 | 0.956 | 0.92 |
| VGG16bn | CoLa-DCE | Attr | feat.37 | 44.43 | 13915 | 0.821 | 0.81 |
| ResNet18 | LDCE | Base | - | 55.86 | 12518 | 0.846 | 0.79 |
| ResNet18 | LDCE | Act | 4.1.c1 | 57.46 | 12502 | 0.96 | 0.91 |
| ResNet18 | LDCE | Attr | 4.1.c1 | 46.28 | 12465 | 0.957 | 0.91 |
| ResNet18 | CoLa-DCE | Attr | 4.1.c1 | 44.86 | 13933 | 0.846 | 0.84 |
| ViT | LDCE | Base | - | 59.48 | 12533 | 0.833 | 0.81 |
| ViT | LDCE | Act | encoder | 53.75 | 14024 | 0.913 | 0.88 |
| ViT | LDCE | Attr | encoder | 53.24 | 14028 | 0.917 | 0.89 |
| ViT | CoLa-DCE | Attr | encoder | 53.21 | 14003 | 0.847 | 0.83 |

While LDCE [] uses WordNet [] to derive counterfactual targets based on the semantic similarity between labels, we suggest using the classifier’s perception of the local input.
Selecting a target layer, the classifier-internal representation of a data point can be extracted via the activation or the attribution using a local xAI method.
Based on the encodings of a reference dataset, the sample with minimal distance and differing class prediction to the encoded target sample is extracted. It’s prediction is chosen as counterfactual target.
The approach is related to the concept of near misses [].

Table 1 shows the influence of the target selection on the generated samples’ quantitative performance metrics.
Choosing a local (sample-based) counterfactual target on a near-miss basis leads to an improved flip ratio and confidence in all settings, demonstrating a nearer decision boundary and more superficial change between the original and target class.
However, retrieving the target via the activation may lead to a slightly increased FID compared to the baseline, as some counterfactual targets have no semantic connection to the original class. Thus, a more substantial semantic change is required.
Using the intermediate LRP [] attribution yields substantial improvements in the minimal change needed while simultaneously achieving high flip ratios. This indicates semantically similar counterfactuals close to the original images.
Including the model’s classification in the intermediate attribution rather than only considering the activation up to the selected layer may better represent how the features in the layer are connected toward the output, comprising top-level semantics between classes. Thus, fewer feature changes are necessary.
Including the results of our CoLa-DCE method, even closer counterfactuals are generated with flip ratios on par with the LDCE baseline.
Reconsidering the hard constraint on the number of concepts, damping the gradient signal, CoLa-DCE yields much more transparent counterfactuals while still being competitive to the baseline.

### 5.2 The number of concepts is a tradeoff between accuracy and comprehensibility

Since a counterfactual explanation should depict the minimal semantic change in an image that causes a classifier to change its prediction, we assume that the minimal semantic change can be expressed by the number of changed features or concepts.
While generally concept-based approaches in xAI mostly use a handful of concepts for best comprehensibility [, , , ], restricting the latent space gradient in our case from multiple hundred to very few channels significantly reduces the gradient for guiding the diffusion process.
We perform a quantitative study to assess how the number of concepts influences the performance in obtaining reliable results regarding accuracy and minimality.

Figure: (a) Tradeoff between FID and Flip Ratio
Refer to caption: x3.png

Figure: Figure 4: CoLa-DCE explanations (“water ouzel” to “red-backed sandpiper”) with a differing number of concepts $k$ and and the VGG16bn with concept layer 40. Limiting the concept number induces more fine-grained feature perturbations than the baseline LDCE, flipping the shown bird completely.
Refer to caption: x5.png

Figure 3 depicts the relationship between the number of concepts, the FID similarity, and the flip ratio.
Restricting the number of concepts leads to an improved FID (minor change) while the flip ratio decreases.
The restriction of the gradient causes the image to change in fewer features, but the force pushing the sample towards the counterfactual class is also attenuated.
However, a good performance >75% regarding the flip ratio can already be achieved with only ten concepts, while the FID score outperforms the baseline.
Thus, CoLa-DCE offers concept-based transparency and control without losing much detail or accuracy.
Figure 3(b) depicts the tradeoff between minimality and accuracy for multiple model architectures and settings.
Adding spatial constraints per concept results in slightly degraded flip ratios, compensated by an improved FID.
Figure 4 shows an example of how the number of concepts influences the counterfactual generation. Restricting the concepts leads to minor changes that alter the target object semantically. In contrast, multiple hundred concepts and the LDCE baseline induce an alteration of the image composition by, e.g., generating new objects like the vertically flipped bird evolving from the upper part of the original bird.

### 5.3 Spatial constraints per concept improve the focus

Figure: Figure 5: Comparison of the counterfactual images and their explanations for LDCE and our proposed method CoLa-DCE w/o and with spatial constraints.
Refer to caption: extracted/5640165/imgs/spatial_comparison_vgg16bn_40_10_00008.png

Assuming each feature is locally restricted and may only be modified in the most probable region(s), we add spatial constraints per concept by thresholding the gradient.
Considering the example of Figure 1, image modifications towards the cockscomb are only reasonable near the head of the hen so that the concept-based gradient can be set to zero in all other regions. Figure 5 shows the difference in the generated counterfactuals for the spatial conditioning and basic CoLa-DCE compared to the LDCE baseline.
Compared to LDCE, CoLa-DCE yields much more sparse explanations, highlighting fewer and more concentrated feature changes in the image.
With added spatial constraints, a stronger focus in the explanation becomes apparent, either having more sparse explanations or reflecting a stronger focus on single semantic features.
Performance-wise, the spatial conditioning further decreases the FID for the better, while only slight drawbacks regarding the flip ratio occur.

### 5.4 How can concept-based counterfactuals help in explaining model failures?

Counterfactuals are especially useful when explaining samples at the classifier’s decision boundary between two classes.
When misclassified samples and their correctly classified counterfactuals are inspected using our CoLa-DCE approach, the root cause of the misclassification in terms of identified or missing features becomes apparent.
Figure 6 describes a misclassification case where the original image lacks specific evidence of belonging to the label “brambling”.
The sample seems to represent a rare case of the class where the classifier is missing essential concepts shown in the CoLa-DCE explanation for a correct classification.
Hence, a dataset or model adaptation is required.

Figure: Figure 6: A CoLa-DCE explanation for a misclassified sample, which the VGG16bn classifies as “Junco, Snowbird”. To classify the input correctly as “Brambling”, the orange chest color, a slightly different feather pattern, and a gray-blueish head color are missing. Besides, the head and beacon shall look less similar to the class “Junco, Snowbird”.
Refer to caption: x6.png

### 5.5 Validity: Do the concepts align with the image modifications towards the counterfactual?

Testing the validity of our approach considering the selected concepts, we review whether the change from the original to the counterfactual image targets the selected concepts.
The difference in the intermediate attributions of both original and counterfactual images signifies the difference in the importance of the concepts for the respective predictions.
We assume the channels with the highest difference to align with the $k$ selected concepts.
For estimating the relative alignment, we compute the ratio of the difference $|attr_{counterfactual}-attr_{original}|$ for the selected concepts to the top-$k$ values.
The same ratio with $k$ randomly selected concepts is computed for comparison.
The results in Figure 7 clearly validate the concept-based approach, as the meaningful change towards the counterfactual can evidently be assigned to the selected concepts for both the VGG16bn and the ResNet18.
Due to the redundancy of similar feature encodings in computer vision models, a change in one feature is expected to influence multiple channels in the latent space.
Thus, it is reasonable that the selected features do not perfectly align with the top-$k$ concepts with the highest attribution difference.

Figure: (a) VGG16bn
Refer to caption: extracted/5640165/imgs/violin_vgg16bn_40.png

## 6 Limitations

The main limitation of our CoLa-DCE approach is its reliance on a well-trained diffusion model that can accurately reconstruct an image and match the concept information derived by the external classifier.
Like in LDCE, multiple parameters adjusting the influence of the external gradient to the reconstruction accuracy require fine-tuning for an optimal result. They optimize between a minimal image deviation and a maximal flip ratio. It provides an opportunity for individual optimization but requires an exhaustive parameter search.

## 7 Conclusion

Our CoLa-DCE method generating concept-guided counterfactuals successfully tackles the lack of transparency and fine-grained control in current diffusion-based counterfactual generation methods.
Starting from an improved target selection incorporating the models’ perception, we show how our concept-based approach yields semantically smaller image changes qualitatively and quantitatively, enforcing the minimality requirement.
With the additional level of control by selecting concepts and adding spatial constraints per concept, the counterfactual generation is more focused on small, localized feature perturbations in the image.
At the same time, the image alterations are more locally confined and comprehensible due to the concept grounding.
From our CoLa-DCE explanations, it is directly deducible which feature changes at which location cause the prediction change of the classifier, strongly improving the transparency and understandability to a human user.
With the high degree of control in generating images with CoLa-DCE, we are confident to induce further work using fine-grained concept guidance for image alteration tasks.

## Acknowledgement

We thank Simon Schrodi for helpful discussions. Further, we thank Marius Kaestingschaefer, Kostadin Cholakov and Andreas Gilson for their valuable feedback.

## Appendix A Appendix / supplemental material

### A.1 Implementation Details

The implementation of CoLa-DCE is based on the LDCE [] implementation, which is available on GitHub [https://github.com/lmb-freiburg/ldce](https://github.com/lmb-freiburg/ldce).
Adaptations have mainly been made to the scoring function, deriving the gradient-based guidance for the diffusion model.
For computing concept patches to visualize the concepts, the CRP [] implementation from [https://github.com/rachtibat/zennit-crp](https://github.com/rachtibat/zennit-crp) has been used.
For optimization, the concept conditioning is relaxed in the last 50 steps of the diffusion generation to use the complete gradient for image refinement.
To our knowledge, no semantic change in the image can be perceived, while mainly low-level features such as edges are refined.
The parametrization in our experiments is not model-specific. It is based on the proposed parametrization in LDCE [] with only the lp-dist parameter changed to 0.01, as a high value might result in significant features being removed again during the diffusion process.
Optimizing the parameters based on the used model is expected to affect the generated counterfactuals positively.
Our implementation for CoLa-DCE is accessible at [github.com/continental/concept-counterfactuals](github.com/continental/concept-counterfactuals).

On ImageNet, one run of the CoLa-DCE code for a single set of parameters and 1000 images on a NVIDIA RTX A5000 takes approximately 16 hours with a batch size of 4. A single generation step takes slightly less than 3 minutes on the same hardware.
The code should be similarly efficient as the LDCE code from their GitHub.

### A.2 Models and Datasets

The following datasets and models have been used in this paper. Images in the main paper originate from the ImageNet dataset.

**Table 2: Dataset Specification**
| Dataset | License | URL |
| --- | --- | --- |
| ImageNet [] | Custom | [https://www.image-net.org/index.php](https://www.image-net.org/index.php) |
| Oxford Flowers 102 [] | GNU | [https://www.robots.ox.ac.uk/vgg/data/flowers/102/](https://www.robots.ox.ac.uk/vgg/data/flowers/102/) |
| Oxford-IIIT Pet [] | CC BY-SA 4.0 | [https://www.robots.ox.ac.uk/vgg/data/pets/](https://www.robots.ox.ac.uk/vgg/data/pets/) |

Table: Table 3: Model Specification

### A.3 Further CoLa-DCE Examples

For the Flowers and Pets datasets, a VGG16bn has been finetuned on a few epochs until decent accuracy of over 85%.

Figure: Figure 8: CoLa-DCE example for an ImageNet sample and the VGG16bn model. The counterfactual with class “Great White Shark” is modified in the head structure with more forward-facing eyes and a sharper, pointed nose. Also, the mouth section is adapted to the counterfactual class.
Refer to caption: x7.png

Figure: Figure 9: CoLa-DCE example on the ImageNet dataset from “Bullfrog, Rana Catesbelana” to “Tailed Frog, Bell Toad”.
Refer to caption: x8.png

#### A.3.1 Oxford Pets dataset:

Figure: Figure 10: CoLa-DCE example on the Pets dataset from “Abyssinian” to “Maine Coon”.
Refer to caption: x9.png

Figure: Figure 11: CoLa-DCE example on the Pets dataset from “American Bulldog” to “Boxer”.
Refer to caption: x10.png

#### A.3.2 Oxford Flowers dataset:

Figure: Figure 12: CoLa-DCE example on the Flowers dataset from “Pink Primrose” to “Peruvian Lily”.
Refer to caption: x11.png

Figure: Figure 13: CoLa-DCE example on the Flowers dataset from “Hard-leaved Pocket Orchid” to “Carnation”.
Refer to caption: x12.png

### A.4 A Discussion on Adversarial Examples

While counterfactuals are supposed to be semantic changes in an input image, there is always the possibility that single pixel changes in an image trigger the classifier to predict a different targeted class.
These changes are named adversarial examples.
While there is no guarantee that a generated image does not include adversarial pixel changes, we highlight the functionality of CoLa-DCE and LDCE as an ensemble of models that makes the appearance of adversarials unlikely.
For the counterfactual generation on ImageNet data, the class-conditioned diffusion model and the external classifier are trained on the same data so that similar shortcuts can potentially be learned.
However, the classifier is trained to discriminate between classes, while the diffusion model is trained to generate semantic class features and to represent the data distribution in a semantic encoding.
A potential adversarial signal would need to be encoded in the gradients of both models to be included into the gradient alignment, which is used for guiding the diffusion process.
As additionally latent diffusion is used, the encoded representation needs to be decoded to a human-observable image in input space by the trained decoder, which would be required to preserve the adversarial signal and reconstruct it into the respective image pixels.
We argue that the probability of such a signal fitting a possible adversarial trigger in the external classifier is relatively low.
With the usage of concept-based conditioning, the concept-gradient of the external classifier is used, directly pointing out which features should be changed in which areas of the input image.
This level of control and semantic guidance is another factor diminishing the probability of adversarial patterns.
While the dataset might induce semantically wrong class patterns in all related models, we argue that these patterns represent valid dataset features requiring a dataset adaptation. They can be easily found by inspecting the concept patches given in our CoLa-DCE explanations.

### A.5 Comparison of LDCE and CoLA-DCE counterfactuals

Figure: Figure 14: Comparison of generated samples between LDCE and our CoLa-DCE. The CoLa-DCE samples include fewer feature changes and even look more realistic for some examples.
Refer to caption: x13.png

Figure: Figure 15: Comparison of generated samples between LDCE and our CoLa-DCE.
Refer to caption: x14.png

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 5
presentation: 3
questions: 1. Following up from the weaknesses outlined above, have you considered using additional evaluation metrics, such as cosine similarity between CLIP embeddings or targeted model embeddings, to provide a more in-depth analysis of the differences between the original and generated images?

2. Have you conducted human study to validate the usefulness of the proposed method in model debugging?
soundness: 3
strengths: - The paper is well written and the problem is well motivated. The current concept generation methods are lacking control, although some efforts have being made to control this generation [1, 2], but not this level of fine-grain control.
- The usability of the proposed method in diagoning model failure makes it a good contribution for evaluating robustness and fairness of practical systems.

**References: (Can be included in related work)**
1. Vendrow, Joshua, et al. "Dataset interfaces: Diagnosing model failures using controllable counterfactual generation." arXiv preprint arXiv:2302.07865 (2023).
2. Prabhu, Viraj, et al. "Lance: Stress-testing visual models by generating language-guided counterfactual images." Advances in Neural Information Processing Systems 36 (2023): 25165-25184.
summary: The author proposes a novel method, CoLa-DCE (Concept-guided Latent Diffusion Counterfactual Explanations), to generate controlled counterfactual explanations for image classification models using latent diffusion models. CoLa-DCE addresses a significant limitation of transparency in existing counterfactual generation techniques, where changes are applied and what is altered. Further, they show the usability of their method in debugging a model by making cases of misclassification more understandable.
weaknesses: **Major:**
- **Evaluation of the proposed method:**
  - In line 295, the authors mention using both L1 and L2 norms to evaluate the method. However, in Table 1, only the results for the L1 norm are shown.
  - While the proposed method consistently achieves the best FID score, it doesn’t surpass the baseline in most other metrics. Although the FID score is lower (indicating better quality), the difference between the best and second-best scores is relatively small. Moreover, when considering Flip Ratio (which shows how often the classifier predicts the counterfactual class), the gap between the proposed method and baseline is more noticeable.
  - Additionally, it may be helpful to consider other metrics, such as cosine similarity between CLIP embeddings (or embeddings from the target model), as these could offer better insights than the direct L1 and L2 norms between the original and generated images.

- **Lack of Human Study:** A human study could strengthen the paper, especially since the authors suggest that their method could be useful in model debugging and understanding model failure. A user-focused study demonstrating the method’s practical benefits would effectively support this claim.

**Minor:**
- The **url of the code** provided in line 100 is not working.

---

confidence: 3
contribution: 3
initial_rating: 3
presentation: 1
questions: Writing related questions or doubts are listed in Weaknesses. These are some other questions I have:

1. How do you obtain the influence of each concept? I couldn't find its description in Sec. 4. Please point me where it is described.

2. Did you consider comparing with [1]? I guess LDCE is your primary baseline but I would like to know your thoughts about this paper too.

3. About the claim in line 71--72 "it is often unclear which features precisely change toward the counterfactual and how they relate to the model prediction". Is this only a qualitative observation here or are there also some references to support it? While qualitatively I sort of understand this, I think it still is somewhat of an issue visually with CoLA-DCE because it visually seemed very similar to LDCE (like in Fig. 5). Some of the tools like gradient visualisation you use can still be used with LDCE (as In Fig. 5). It confuses me to what extent CoLa-DCE itself has solved this problem? Can you comment on this please. The positive for CoLa-DCE I do notice clearly is the sparsity of attribution maps. 

4. Lastly, to visualise the changes did you consider simply taking the difference of the counterfactual and original images?

[1] Text-to-Image Models for Counterfactual Explanations: a Black-Box Approach. WACV 2024


Overall, despite some nice ideas and experiments, I am disappointed by the writing and not convinced by the quantitative results. Thus, I will favour rejection.
soundness: 2
strengths: 1. The proposed system is novel, further exploring use of latent diffusion models for counterfactual explanations.
2. The authors clearly illustrate applicability on multiple datasets and classifier architectures.
3. The idea to use spatial conditioning to guide the modifications is interesting.
summary: The paper proposes a novel system CoLa-DCE based on using latent diffusion models for visual counterfactual explanations. The main contribution of the paper is to introduce a method of concept selection and spatial conditioning to control generation process of counterfactual images. They also introduce feature visualisation tools to better identify the location of modifications. The authors demonstrate applicability of their method on multiple datasets, classifier architectures and diffusion models.
weaknesses: 1. Writing should be seriously improved.  It is really tedious to get through the paper. Often terms are not defined properly and the reader really has to rely on the context to understand used terms. This is not possible always. See a list of writing issues below:
	* I find parts of Fig. 2 unclear. The caption should describe the key features of the model. Why is there a connection between Decoder and External classifier but no arrow. What is it supposed to mean? 
	* line 224 Should describe $d, \kappa$ clearly and what they denote. Is the feature encoding coming from an external network, the classifier $f$ itself etc. What is the distance metric? Euclidean distance?
	* Implicit/Explicit classifier should be described clearly when describing CoLa-DCE in Sec. 4. What is their input, output domains, what are their roles etc. I guess one of them is $f$. I assume they originate from prior literature but they also seem central to your method so need clear concise description.  
	* line 249: Should define $\mathcal{N}$ or state its the set of natural numbers (can be confused with normal distribution as you use it in Eq. 1). 
	* line 259 Why is the external classifier modelled as p(x|y) (which should be for diffusion model). Wouldn't the classifier be modelled as p(y|x)? 
	* The notations $h, g$ almost appear out of the blue. What are their input, output domains. It is the same issue with $\delta$ but it at least has some brief description.
	* line 260. You provide absolutely no explanation of notations about concepts, how they are represented, what the binary constraints denote exactly. It is difficult to understand $\lambda_1, ..., \lambda_k$ and $\theta_1, ..., \theta_k$. Are the lambda's just subset of natural numbers from 1 to K? Your notation for $\theta$ also does not seem consistent. For starters, line 236 has it going from 0 to k while at other places it is 1 to k. More importantly, Eq. 7 makes it seem like $\theta$'s denote subset of indices but they are supposed to be binary masks. I am not sure what are these representations exactly, beyond the basic idea that they control which concepts to condition on.
	* There are two terms for datasets (line 219, 226) $X', \hat{X}$. What is the difference between the two? Is the reference data classification training/validation dataset and the other test data? 
	* line 222 "As the model perception of the data shall be represented, the class predictions of the model are used to determine class affiliation." Really odd phrasing, please make it more clear.
	* line 319-320 "Using the intermediate ... high flip ratios" I am not sure how you are drawing this conclusion from Tab. 1. Please elaborate on this how you come to this conclusion.
	* line 469 What is $attr$ supposed to denote exactly. The attribution map for a particular feature/concept? If yes, why are you computing absolute magnitude for relative alignment? Is it the Frobenius norm of the difference of attributions? It should be described more clearly.
	* Please explain more clearly what the "confidence" metric is? Is it the difference between classifier's probability for the initially predicted class before and after the modifications? 
        * line 295 mentions l2 norm between original and counterfactual image. Was it supposed to be a metric in Tab. 1?

2. The quantitative metrics of CoLa-DCE seem weak. LDCE seems to clearly outperform CoLA-DCE on "Flip-ratio" and "Confidence" metrics while being close on FID.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: In the Weakness section, I blended the specific drawbacks of the method with the questions connected to them, which I will be happy to receive answers to. Besides a minor comment below, I would like the authors to focus on addressing the weaknesses, as they are concerned with the fundamental assumptions standing behind the introduction of the proposed algorithm. Overall, I think that the paper would benefit from more detailed descriptions of each component of the proposed approach, possibly also extending the introduced pseudocode.

C1. The authors incorrectly state that the DiME method `is limited to robust classifiers explicitly trained on noisy images`. In fact, the method is proposed for standard, non-robust classifier.
soundness: 2
strengths: S1. The paper succesfully incorporates concept conditioning into the LDCE pipeline without significant losses in performance.

S2. The experimental evaluation is based on diverse experiments addressing various important research questions. The main results are further supported by experiments on other datasets shown in the appendix. The shown explanations look realistic and correctly flip the model's decision to the target class.

S3. The authors clearly state the limitations of previous works and the motivation behind the introduction of CoLa-DCE. The related works section properly mentions the most significant papers from the field and the algorithms on which CoLa-DCE builds upon.
summary: The paper is concerned with the problem of generating visual counterfactual explanations (VCEs) for predictive models in computer vision. Motivated by the human perception, which is based on semantic features and concepts, the authors propose to adapt an existing LDCE algorithm to incorporate concept-conditioning, resulting in Concept-guided Latent Diffusion Counterfactual Explanations (CoLa-DCE). This is achieved by utilizing Concept-wise Relevance Propagation (CRP) to extract the concepts important to the classifier and then using them as additional constraint throughout the explanation generation process. The combination of the two methods allows for additional visualizations, where the important concepts are included next to the VCE. Following previous works, the proposed approach is evaluated with 4 classifiers on the ImageNet dataset. Experiments attempt to verify the influence of the local target selection, the chosen number of concepts, spatial constraints, how the resulting explanations may help in explaining model failures and the alignment of concepts with the introduced edits.
weaknesses: W1. Following the paper's narrative, the main contribution of the proposed method is its focus on `local counterfactual targets`,  `concept-guided feature changes` and `minimality by restricting the number of feature changes`. However, to the best of my understanding, the resulting explanations do not address these aspects explicitly. For example, looking at Figures 1., 6., 8. and 9., the presented counterfactuals modify the entire image and do not restrict the edits to areas indicated by the concept visualizations. I suspect that this phenomenon might be caused by a) the spatial constraints being introduced only at the semantic latent space level b) `suspending the concept conditionining for the last 50 generation steps`. Because the source code was not yet provided, I am not able to verify that by myself. Irrespectively of the cause, my biggest concern is that in the end the method still modifies the entire image and hence does not fulfill the main promise of the paper. Therefore, one cannot be certain whether the model's decision flip was actually caused by the edits inside areas connected to concepts or a combination of those and the complementary areas. I am leaning towards the latter claim, as the authors explicitly state that `suspending the conditioning towards the end of the generation, visible semantic changes are not perceivable, but the image is classified more accurately`, meaning that modifying other areas also influences the classifier. Overall, I must argue that this point requires further elaboration from the authors.

W2. Another contribution of the paper described in the first section is generally connected with the improved quality of the obtained explanations, which are `more transparent` and `more comprehensible`. I must argue that these claims are not properly supported with any of the quantitative results shown in the work. For example, Table 1. shows that CoLa-DCE is able to slightly improve FID but at a visible cost of L1, Flip Ratio and Confidence. These results suggest that the method struggles to improve upon the baseline LDCE. Figure 3.(a) shows that even when the number of concepts gets close to 200, CoLa-DCE remains inferior to LDCE, while also failing to beat it in terms of FID. Figure 3.(b) only compares the method with its variation. Further results from the Appendix (Tables 4. and 5.) suggest that the methods performance does not follow a predictable trend when increasing the number of concepts, once again struggling to beat the baseline in many cases in terms of Flip Ratio and Confidence. Some specific cases are also concerning, as one would not expect that moving from 50 to 100 concepts would drastically decrease the Flip Ratio (see Table 5.).

W3. The overall description of the method and the methods directly related to it (Section 3.2 with CRP description, Section 4 concerned with the entire pipeline) is kept at a rather high level, making it hard to understand the specific details. For example, I was not able to grasp how concept and spatial conditioning differ from each other based on the provided descriptions, i.e. from where exactly the binary constraints come from in each case. The pseudocode (Algorithm 1) combines those two into a single line and does not elaborate on the topic further. While the constraints are mentioned in line 238 (Algorithm 1), the gradient here is taken wrt. the latent representation, while Section 4.3 uses the `x` symbol, somehow indicating that constraints are performed in the input space. In addition, while the authors clearly motivate why a specific target class is chosen (`model perception`), the paper does not show whether CoLa-DCE is able to generate explanations for class pairs shown in previous works, putting in question the general applicability of the algorithm.

W4. Following W1., I would like the authors to clarify for which class the aforementioned figures show the attributions maps. Assuming that the convention from Figure 1. is followed, I do not fully understand the added value of these visualizations, as the initial attribution map for the target class is not shown in any case. Also, do the visualizations depict all concepts utilized in the explanation generation? As the quantitative results are typically shown for the number of concepts much greater than 5, I suspect that the figures mentioned in W1. only show the most important concepts, which I would argue does not fully support improving the explanation comprehensibility.

W5. Minor: the citation feature is not properly used, disabling the hyperlink functionality and forcing the reader to manually search through the referenced works.

Meta-review: The paper proposes CoLa-DCE (Concept-guided Latent Diffusion Counterfactual Explanations), a novel method that generates controlled counterfactual explanations for image classification models using latent diffusion models. The method introduces concept-based spatial conditioning and incorporates Concept-wise Relevance Propagation (CRP) to determine where and which concepts to modify, addressing key limitations in existing counterfactual generation methods. CoLa-DCE is demonstrated on multiple datasets and classifiers, showcasing its utility for debugging misclassifications and improving model transparency.

Strengths

+ The method is novel, extending latent diffusion models to include concept-guided conditioning for controlled counterfactual generation.
+ CoLa-DCE demonstrates applicability across multiple datasets, classifiers, and diffusion models, indicating its broad potential.
+ The paper is well-motivated, addressing the need for transparency in counterfactual explanations and practical utility in diagnosing model failures.
+ Visual explanations produced by CoLa-DCE appear realistic and effectively flip the model’s predictions.

Weaknesses

+ Quantitative Evaluation: Table 1 only reports L1 norms despite L2 being mentioned in the text. While CoLa-DCE achieves improved FID scores, it underperforms baselines like LDCE on key metrics such as Flip Ratio and Confidence. Additional metrics (e.g., cosine similarity between embeddings) could provide better insights into the image modifications.
+ Human Study: The lack of a user study weakens claims about the method’s practical usefulness in model debugging.
+ Writing and Clarity: The paper suffers from unclear and inconsistent descriptions of key terms, methods, and notations (e.g., concept constraints, spatial conditioning, and binary masks). Figures and captions, particularly Fig. 2 and attribution maps, lack sufficient explanations. Certain claims, such as improved explanation transparency, are not fully supported by the results.
+ Key Concerns: Despite claims of minimal edits guided by concepts, the counterfactuals appear to modify entire images rather than specific areas. Suspended concept conditioning in the final generation steps raises doubts about whether changes are concept-driven. General applicability of CoLa-DCE to class pairs shown in prior works is not demonstrated.

Decision: Reject