junfu1115 / DANet

Dual Attention Network for Scene Segmentation (CVPR2019)
MIT License
2.41k stars 483 forks source link

请问怎么可视化得到的注意力图 #123

Open swjtulinxi opened 3 years ago

RainHxj commented 3 years ago

118

Yeating commented 3 years ago

同问,是在那个文件的程序里实现的?

lvcat commented 3 years ago

1 Get attention feature from PAM/CAM, you should modify forward code(models/base.py) (feed the whole image to a network) 2 Modify test.py to save attention feature((using np.save(XXX.npy))),shape is BxNxN 3 For PAM, we decode the saved attention feature (using np.load(XXX.npy)), each row is an attention map for the corresponding pixel, then, you can resize img (20481020) to (256128) and get pixel index form image(x,y value), where you need (like one pixel from a person or a car ), the row of the pixel of attention is M = W * y + x, attention[:,M:M+1,:] is Mth attention map for the corresponding pixel. 4 For CAM, when u save the feature map(before/after apply CAM), then u can use opencv(function: applyColorMap) to visualize.