wtyhub / LPN

Pytorch implementation of Each Part Matters: Local Patterns Facilitate Cross-view Geo-localization https://arxiv.org/abs/2008.11646
MIT License
78 stars 13 forks source link

Question about using Grad-CAM #6

Open viet2411 opened 2 years ago

viet2411 commented 2 years ago

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.

wtyhub commented 2 years ago

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.

viet2411 commented 2 years ago

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.

wtyhub commented 2 years ago

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