I’m here to share a library I built for interpretability of keras computer vision models that contain convolutional layers. It produces GradCAM heatmaps in a single function call:
from cnncam import display_heatmap display_heatmap(model=model, # your keras model img=img, # your image predicted_class=pred, # your models prediction for the image layer_name='block5_conv3', # the layer you would like to see alpha=0.6 # opacity of heatmap overlayed on image )
The output represents a localization of features that were found to be important to the model’s prediction. Below is the implementation tested at various layer depths of VGG16:
pip install cnncam. This project is still on an experimental lifecycle, so if you’d like to contribute, feel free to submit an issue/PR on github.com/rawanmahdi/cnncam. I’m interested in having it work on PyTorch models as well so contribututions are greatly welcomed!
Thanks for the read!