pytorch-grad-cam icon indicating copy to clipboard operation
pytorch-grad-cam copied to clipboard

Grad-Cam mask tutorial

Open CristianCosci opened this issue 3 years ago • 3 comments

Hi! I made this notebook tutorial to learn how to get and reuse a mask returned from grad-cam information. The notebook is currently a draft, I created the pull request to get feedback, in order to know if this work could be considered useful or not. In the event of a positive response, I can make any corrections deemed necessary and improve the text and layout of the notebook :smile:.

CristianCosci avatar Aug 26 '22 08:08 CristianCosci

Hi Cristian, thanks a lot for the PR.

I think a notebook on using the CAM results for different masks is great, but I think it needs some additions for the most common use cases:

  1. Generate a threshold based on the Q'th percetntile, for example keep only the 20% of the pixels with the highest values, and then generate a binary mask with this threshold.

  2. Use an adaptive thresholding like otsu's method that's implemented in opencv, to binarize the CAM.

  3. Alternatively, just multiply the CAM (not the binary mask) by the RGB image itself !

And as a bonus: Use the CAM to extract bounding boxes.

jacobgil avatar Aug 27 '22 12:08 jacobgil

Hi! 😄 I am very happy that such a notebook can be found useful. I am aware that the notebook I currently loaded is very poor, but I created it because I wanted to give an idea of what I was going to do. Now I make a commitment and make all the necessary adjustments and changes that you suggested (I think it will take me some time because these days I am full of work, but I promise to finish as soon as possible 💪). Thank you very much! 💯

CristianCosci avatar Aug 27 '22 13:08 CristianCosci

I just want to pipe in and say Ive need to do some of this as part of my work. I havent yet looked at bounding boxes fully but also something I need to do.

For me its more on the input side rather than output side but once I get to this part of my work Im happy to check out this notebook and possibly add stuff.

Just saying this would be a much appreciated addition

TRex22 avatar Nov 05 '22 22:11 TRex22