pytorch-grad-cam
pytorch-grad-cam copied to clipboard
Grad-Cam mask tutorial
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:.
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:
-
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.
-
Use an adaptive thresholding like otsu's method that's implemented in opencv, to binarize the CAM.
-
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.
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! 💯
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