wtyhub/LPN

Question about using Grad-CAM

Opened this issue · 3 comments

Hello,

Thank you for your great work.

I was trying to use the draw_cam.py script to extract heatmap from results, but there were some errors occured during the experiment, and I do not really understand the problem here:

Traceback (most recent call last):
File "draw_cam.py", line 115, in
draw_CAM(model, img_path, save_path, transform=data_transforms, visual_heatmap=False)
File "draw_cam.py", line 42, in draw_CAM
output.register_hook(extract)
File "/.pyenv/versions/anaconda3-2021.05/lib/python3.8/site-packages/torch/_tensor.py", line 289, in register_hook
raise RuntimeError("cannot register a hook on a tensor that "
RuntimeError: cannot register a hook on a tensor that doesn't require gradient

Could you check the script again and teach me how to solve this problem?
Thank you and best regards.

Hello,
You can try to use heatmap.py to extract heatmap. The script of draw_cam.py may be not work, and I forgot to delete it.

Thank you for your response.
I have one more question about the "Effect of the drone distance to the geographic target" part.
Could you explain about how you divided the dataset into three different parts (Long, middle and short) please?
Thank you and best regards.

I did not divide the dataset. In this experiment. I use "--scale_test" in test.py and select a fixed image index to denote Long or Middle or Short. The indxe=0, index=36 and index=54 refer to the long, middle and short respectively.
image