Implementation of the Grad-CAM algorithm in an easy-to-use class, optimized for transfer learning projects and written using Keras and Tensorflow 2.x.
- Python 3.6.x
- Matplotlib 3.4.x
- Numpy 1.19.x
- Tensorflow 2.4.x
Please take a look of examples folder for a complete example.
from gradcam import Gradcam
gc = Gradcam(model,
layer_name="top_conv",
img_path=img_path,
size=img_size,
inner_model=model.get_layer("efficientnetb0"))
gc.generate_stack_img(save_name="../output/example_out")
[1] Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization.