This is the Keras implementation of GradCam & GradCam++ for explainability of Deep Learning model applied to the kaggle playground competition Dogs vs. Cats Redux: Kernels Edition
Grad-CAM++: Generalized Gradient-based Visual Explanations for Deep Convolutional Networks(https://arxiv.org/abs/1710.11063) by Aditya Chattopadhyay, Anirban Sarkar, Prantik Howlader, Vineeth N Balasubramanian
Some of the important dependencies required are:
- python 3.5
- tensorflow
- Keras
- numpy
- pandas
- matplotlib
- CUDA (for using GPU)
The original dataset can be downloaded from the kaggle competitions page.
After downloading it can be extracted at the current directory (same as that of the zip file downloaded above) by running:
python3 create_data.py
The structure of the working directory is shown below:
.
├── cats-v-dogs
│ ├── testing
│ │ └── test [12500 entries]
│ ├── train
│ │ ├── cats [11250 entries]
│ │ └── dogs [11250 entries]
│ └── validation
│ ├── cats [1250 entries]
│ └── dogs [1250 entries]
├── create_data.py
├── dogs-vs-cats-redux-kernels-edition.zip
└── sample_submission.csv
(or) For using with Google Colab the you can simply use the zipped working directory from here
For using this data, refer jupyter notebook
For directly viewing the GradCam visualisations with the already pretrained model (can be downloaded from this link),
simply run python3 apply_gradcam.py -i <input-image-path> -m <pre-trained-model>
To train and test the model, simply run python3 train.py
.
Once trained, you can view the gradcam visualisations with your trained model by running python3 apply_gradcam.py -i <input-image-path> -m <saved-model>
(or) Simply run the jupyter notebook file in google colab.
Grad-Cam codes for keras were adopted from https://github.com/totti0223/gradcamplusplus