All the XAI techniques in this repository are using a pretrained Residual Network 50 layers from torchvision.
- Install the dependancies and enter the virtual environment:
poetry install
poetry shell
We made a user interface available so you can seemlessly explain the pictures:
python gradio_app.py
So far we have few supported XAI methods.
- Grad-CAM and HiResCAM:
The Grad-CAM technique consists of highlighting the pixels in the image that are important for the model to make its classification decision [1]. HiResCAM is a generalization of CAM that does not have the same drawbacks as Grad-CAM [2].
python src/xai_methods/cam.py --img ./assets/images/dog.png --output src/xai_methods/dog_hirescam.png --method hirescam
This will give you the following result:
- Deep Feature Factorization:
DFF is a technique that decomposes the image as a set of interpretable components as viewed by the AI algorithm. This allows the visualization and understanding of complex representations learned by the network [3].
python src/xai_methods/dff.py --img ./assets/images/dog.png --output src/xai_methods/dog_dff.png --n_components 2
This will give you the following result:
[1] Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization [2] Use HiResCAM instead of Grad-CAM for faithful explanations of convolutional neural networks [3] Deep Feature Factorization For Concept Discovery