Closed AFOXCOW closed 5 years ago
GradCam.py itself should be the one. In it there is a function to save the images. The other is for the other experiment which I didn’t include in my paper.
Thanks for your reply. I try to follow your paper and use guided-grad-cam to generate the heatmap pics.
` gcam = GradCAM(model=model)
gbp = GuidedBackPropagation(model=model)
probs, ids = gcam.forward(images)
_ = gbp.forward(images)
gcam.backward(idx=ids[i])
regions = gcam.generate(target_layer=target_layer)
gbp.backward(idx=ids[i])
gradients = gbp.generate() `
Above is the main process of using your GradCam_cuda.py(cause the defination of Net arch in GracCam.py is not the same in Training_testing.py, I guess it is used for other purpose as mentioned in your reply) Both gcam and gbp instance`s self.image.grad is nonetype as is shown in pics. Because the grad-cam does not need the grad of input image, it works. But the guied bp did not work which makes the guided grad cam pics can not be generated. Am I using GradCam_cuda.py in a wrong way?
Sorry to bother you again. My bad. It is just a wrong usage of pytorch. I find the solution here. https://discuss.pytorch.org/t/strange-behavior-of-variable-cuda-and-variable-grad/1642
Excuse me. I have a very simple question about visulization in your code. There are only GradCam.py and its cuda version in your code, while no python file to call those functions and generate those final guided-grad-cam pictures. Did I miss something? Sorry to bother you and can you provide the whole .py files? Thanks again!!