Installation¶
PEAL runs on Python 3.9 to 3.11. Install it from PyPI to use it as a library, or clone the repository to reproduce the papers.
From PyPI¶
The distribution is called peal-xai; the import package is still peal,
because the name peal on PyPI belongs to an unrelated project.
pip install peal-xai
That gives the core library: datasets, predictors, the diffusion autoencoder and DDPM generators, the counterfactual explainer, and the CFKD, DiDAE, ClArC and GroupDRO adaptors. Everything else is an extra, listed below.
Warning
The wheel does not carry the 800 experiment configs under configs/, which
live outside the peal package. They ship in the source distribution instead.
If you want to run the documented --config <PEAL_BASE>/configs/... commands,
clone the repository (or unpack the sdist) and point $PEAL_BASE at it.
Loading a config without that raises an error saying so.
From a clone¶
Conda¶
git clone https://github.com/Explainable-AI-Berlin/pytorch_explain_and_adapt_library.git
cd pytorch_explain_and_adapt_library
conda env create -f environment.yaml
conda activate peal
requirements.txt is the exact package set the papers were produced with, and
it is generated from the pip section of environment.yaml. It is deliberately
not what pip install peal-xai uses: those are pinned versions of a whole
research environment, while the published package declares lower bounds. Use
it when you want to reproduce results, not when you want the library.
Apptainer¶
apptainer build python_container.sif deploy/apptainer/python_container.def
apptainer run --nv python_container.sif
Optional extras¶
Each extra backs one part of the library. The code imports these packages
lazily, so a missing extra surfaces as an error naming the install command
rather than breaking import peal.
Extra |
Installs |
Needed for |
|---|---|---|
|
|
the PathLDM generators (Camelyon17, Follicles) |
|
|
the Stable Diffusion 3 generator |
|
|
using an ONNX classifier as the predictor |
|
FastAPI and Flask stacks |
the web demo and the human feedback pages |
|
|
the SpRAy and ViRelAy teachers and the LRP explainer |
|
|
the WILDS datasets (Camelyon17, RxRx1) and Kaggle downloads |
|
|
the Stable Diffusion autoencoder |
|
|
distributed sampling in the DDPM generators; needs a system MPI |
|
|
the image transforms that render through pygame |
|
all of the above |
everything installable from PyPI |
pip install "peal-xai[xai,datasets]"
pip install "peal-xai[full]"
Two things are not installable from PyPI and have their own commands:
Command |
Gives you |
|---|---|
|
OpenAI CLIP, which is not published on PyPI |
|
the modified RAEv2 ( |
Set PEAL_RAEV2_DIR only when the fork lives somewhere PEAL does not look by
itself (it checks the installed peal-xai-rae package, then
packages/peal-xai-rae/peal_rae/RAEv2 in a clone, then ./external/RAEv2).
Commands¶
Installing the package puts twelve commands on your path. Each one is the same
code as the identically named script in a clone, so peal-cfkd --config x.yaml
and python run_cfkd.py --config x.yaml do the same thing.
Command |
Repository script |
Runs |
|---|---|---|
|
|
the CFKD repair loop |
|
|
the DiDAE adaptor |
|
|
an explainer on its own |
|
|
any adaptor from its config |
|
|
generator training |
|
|
predictor training |
|
|
student distillation |
|
|
predictor evaluation |
|
|
sparse dictionary evaluation |
|
|
generator component analysis |
|
|
dataset generation |
|
|
the config check |
All of them take a --config path, so they need the configs described above.
Environment variables¶
Variable |
Default |
Meaning |
|---|---|---|
|
|
where datasets such as CelebA live |
|
|
where every run writes logs, checkpoints and collages |
|
installed |
location of the RAEv2 fork (CC BY-NC 4.0) for the RAE generators |
The placeholder <PEAL_BASE> in config files is the repository root and is
resolved by the library itself; it is not an environment variable.