PEAL: PyTorch Explain and Adapt Library¶
PEAL explains image classifiers with visual counterfactuals and repairs the Clever-Hans strategies those counterfactuals expose. It is the official implementation of the Smoothed Counterfactual Explorer (SCE), Counterfactual Knowledge Distillation (CFKD) and Disentangled Diffusion Autoencoders (DiDAE), and ships re-implementations of the counterfactual explainers and robustification baselines those papers compare against.
PEAL can be used three ways, all driven by the same config files:
Command line –
peal-cfkd,peal-didae,peal-train-predictorand the other commands each run one method from a config file. This is also how the papers’ results are reproduced (reproduction_scripts/).Python API –
import pealgives the config models, factories and methods (peal.CFKD,peal.DiDAE, …); see the API reference.Web interface – upload an ONNX classifier and a dataset, judge the counterfactuals in the browser and download the corrected model.
The user guide walks through all three.
User guide
- Installation
- How the pieces fit together
- User guide
- Three ways to use PEAL
- Example configuration:
configs/my_experiments/adaptors/my_didae.yaml - Executing DiDAE
- Using PEAL components from your own code
- Example workflow: the CFKD adaptor
- Structure of the project
- Licence and citation
- Contribution guidelines
- Web demo (upload an ONNX classifier, get a corrected one back)
Development
API reference