pytorch-grad-cam
pytorch-grad-cam copied to clipboard
How to generate cams along with the predictions themselves?
In my use case, I only need to generate cams for one specific class (I am classifying hole-free and hole-present images). I am wondering if it is possible to generate cams along with actual model output? In an ideal scenario I would like to save inference time because I don't need cams for hole-free images. Thank you for your help.
Hi, were you able to get the model predictions along with the generated CAMs?
The key is to modify this part https://github.com/jacobgil/pytorch-grad-cam/blob/master/pytorch_grad_cam/base_cam.py#L74 For example we could do self.outputs = outputs So then outputs could be accessed outside.
I'm traveling right now so will be able to modify this only later, but this should work.
Hi @jacobgil !
I created a PR to implement this request. Please take a look at your convenience: https://github.com/jacobgil/pytorch-grad-cam/pull/419