This notebook directory has two notebooks demonstrating how to use the Class Activation Mapping API for image classification (ExplainingImageClassification.ipynb
) and object detection (ExplainingObjectDetection.ipynb
) task types.
This notebook demonstrates how to use the CAM explainer API to explain an ImageNet classification example using a RESNET50 CNN from the Torch Vision model hub and also from the TF keras.applications model hub.
ExplainingImageClassification.ipynb
performs the following steps:
- Install and import dependencies
- Load the ImageNet example image to be analyzed
- Load the ResNet50 CNN trained on ImageNet
- Visualize the ResNet50 classification of the loaded image using
x_gradcam()
- Redo steps above for TF keras.applications ResNet50 model and using
tf_gradcam()
To run ExplainingImageClassification.ipynb
, install the following dependencies:
pytorch-grad-cam GitHub Project - https://github.com/jacobgil/pytorch-grad-cam TensorFlow implementation - https://github.com/ismailuddin/gradcam-tensorflow-2/blob/master/notebooks/GradCam.ipynb
This notebook demonstrates how to use the CAM explainer API to explain two ImageNet object detection examples using a FasterRCNN and a YOLO model from the TorchVision and Torch model hubs, respectively.
ExplainingObjectDetection.ipynb
performs the following steps:
- Install and import dependencies
- Load the ImageNet example image to be analyzed
- Load the FasterRCNN trained on ImageNet
- Define the helper functions
- Visualize the FasterRCNN detection of the loaded image using
eigencam()
- Redo steps above for the YOLO model
To run ExplainingObjectDetection.ipynb
, install the following dependencies:
- Intel® Explainable AI
pip install scikit-image ultralytics
pytorch-grad-cam GitHub tutorial for object detection with FasterRCNN - https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Object%20Detection%20With%20Faster%20RCNN.html pytorch-grad-cam GitHub tutorial for object detection with YOLO - https://jacobgil.github.io/pytorch-gradcam-book/EigenCAM%20for%20YOLO5.html