在mmdetection的github项目中找到一些CAM的相关内容
How to generate the feature heat map of the detection network? #7989
[WIP] Support Grad Free and Grad Based CAM #7987


如何 从 Pull Request 下载变更文件
1.访问的链接是一个 Pull Request(#7987)的文件差异页面。可以打开 PR 页面: → https://github.com/open-mmlab/mmdetection/pull/7987
2.点击 “Files changed” 标签页
3.找到需要下载的文件,点击右上角的 … → “View file”
4.在文件页面点击 “Raw” 按钮,再保存或下载
下载vis_cam.py和det_cam_visualizer.py,分别将其放在指定路径下。


踩坑记录

det_cam_visualizer.py文件中,由于版本更新,np.long换成np.int64,并且文件中的use_cuda 参数全部需要注释掉。否则执行vis_cam.py时会报错。
det_cam_visualizer.py 函数逐行解读记录
使用方式
# FeatmapAM method
python demo/vis_cam.py demo/demo.jpg configs/retinanet/retinanet_r50_fpn_1x_coco.py retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth
# EigenCAM method
python demo/vis_cam.py demo/demo.jpg configs/retinanet/retinanet_r50_fpn_1x_coco.py retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth --method eigencam
# AblationCAM method
python demo/vis_cam.py demo/demo.jpg configs/retinanet/retinanet_r50_fpn_1x_coco.py retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth --method ablationcam
# AblationCAM method and save img
python demo/vis_cam.py demo/demo.jpg configs/retinanet/retinanet_r50_fpn_1x_coco.py retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth --method ablationcam --out-dir save_dir
# GradCAM
python demo/vis_cam.py demo/demo.jpg configs/retinanet/retinanet_r50_fpn_1x_coco.py retinanet_r50_fpn_1x_coco_20200130-c2398f9e.pth --method gradcam

8684

被折叠的 条评论
为什么被折叠?



