Instructions to use cairo-thws/XAIDIFF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use cairo-thws/XAIDIFF with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("cairo-thws/XAIDIFF", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,40 +1,7 @@
|
|
| 1 |
-
#
|
| 2 |
A framework for local example-based explanations with generative models.
|
| 3 |
The code is published at [Github](https://github.com/cairo-thws/XAIDIFF)
|
| 4 |
The pretrained models can be found at [Huggingface](https://huggingface.co/cairo-thws/XAIDIFF).
|
| 5 |
|
| 6 |

|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
# About this repository
|
| 11 |
-
This repository contains the code for the XAIDIFF framework.
|
| 12 |
-
The framework is designed to provide local example-based explanations for image- and object classifiers with the help of generative models.
|
| 13 |
-
Using a diffusion model, the framework generates counterfactual examples that are similar to the input image but are classified differently by the classifier.
|
| 14 |
-
The framework is designed to be modular and can be used with different generative models and classifiers.
|
| 15 |
-
|
| 16 |
-
# Installation and usage
|
| 17 |
-
|
| 18 |
-
## Conda environment
|
| 19 |
-
First, create a new conda environment and activate it.
|
| 20 |
-
```
|
| 21 |
-
conda env create -f environment.yml
|
| 22 |
-
conda activate xaidiff
|
| 23 |
-
```
|
| 24 |
-
|
| 25 |
-
## Sampling
|
| 26 |
-
Per default the project allows you to sample from any pretrained diffusion model with any pretrained classifier.
|
| 27 |
-
The `SportBallsDataset` is a simple example dataset that can be used to test the framework.
|
| 28 |
-
If you want to add your own classifier and dataset, just inspect the `SportBallsDataset`.
|
| 29 |
-
|
| 30 |
-
The file `experiment_sampling.py` contains the core functionality of this project and can be used to sample from the models.
|
| 31 |
-
There are many configurable parameters at the head of the file that can be used to adjust the sampling process.
|
| 32 |
-
It will generate counterfactual examples for the given input image and classifier.
|
| 33 |
-
|
| 34 |
-
The results contain the following information:
|
| 35 |
-
- An image with four rows: the original image, the counterfactual sample, an affirmative sample and an adversarial sample.
|
| 36 |
-
- Different metrics for the generated samples, including LP distances and bits per dimension. This allows to compare the generated samples with the original image.
|
| 37 |
-
|
| 38 |
-
The file `experiment_sampling_sportsballs.py` contains an example of how to adapt the original sampling process to the `SportBallsDataset`.
|
| 39 |
-
To execute it, download the pretrained sportballs classifier and diffusion model.
|
| 40 |
-
|
|
|
|
| 1 |
+
# Model Repository for XAIDIFF
|
| 2 |
A framework for local example-based explanations with generative models.
|
| 3 |
The code is published at [Github](https://github.com/cairo-thws/XAIDIFF)
|
| 4 |
The pretrained models can be found at [Huggingface](https://huggingface.co/cairo-thws/XAIDIFF).
|
| 5 |
|
| 6 |

|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|