This repo helps you to perform GradCAM and GradCAM++ on the detectron2 model zoo. It follows other GradCAM implementations but also handles the detectron2 API specific model details. Be sure to have the latest detectron2 version installed.
There is also this repo to do GradCAM in detectron2. It advises you to make changes to the detectron2 build which I think is not a good idea..
Original | GradCAM (horse) | GradCAM++ (horse) |
---|---|---|
For doing this, check the main.py
and change the img_path
, the config_file
and the model_file
according to your needs.
For ResNet50 models the layer backbone.bottom_up.res5.2.conv3
will be a good choice for the classification explanation. For larger or smaller models, change the layer accordingly via layer_name
.
For your custom models, either write your own config.yaml or edit cfg_list
There's also a Colab with everything set up: GradCam Detecteron2