# GitHub Repository for XAIDIFF
-A framework for local example-based explanations with generative
models

(anonymized ICML 2024 submission)

![XAIDIFF Framework](XAIDIFF.png)


## Conda environment
```
conda env create -f environment.yml
conda activate xaidiff
```

## Training models
Specify the hyperparameters in the xaidatasets/utils.py config.
```
python3 classifier_training.py --dataset {celeba/mnist} --device {gpu_idx/cpu}
python3 diffusion_training.py --dataset {celeba/mnist} --device {gpu_idx/cpu}
```
## Sampling from the models
Specify the hyperparameters in the xaidatasets/utils.py config.
```
python3 diffusion_sampling.py --dataset {celeba/mnist} --device {gpu_idx/cpu}
optional:
--classifier_guidance_scale 
--adam_step_size
--structural_guidance_scale
--sampling_image_indices 
--sampling_target_class 
--structural_guidance_lpdistance {1/2}
```

## Sampling from the models
Evaluate the Weights & Biases runs:
```
python3 evaluate.py --dataset {celeba/mnist} --path {path to saved image tensors from sampling run}

```

## Model files
[Download on Huggingface](https://huggingface.co/anonymous-115102012024/XAIDIFF)
{"language": ["en"], "license": "mit", "library_name": "diffusers", "tags": ["pytorch", "diffusers", "ddpm", "xai", "counterfactual explanations"]}
diffusers safetensors pytorch ddpm xai counterfactual explanations en license:mit region:us