haofanwang / Score-CAM

Official implementation of Score-CAM in PyTorch
MIT License
399 stars 66 forks source link

evaluation using average drop / increase #30

Open yinliu13 opened 1 year ago

yinliu13 commented 1 year ago

Hi, did you include the code on Average Drop and Increase In Confidence?

haofanwang commented 1 year ago

No, but it should be easy to implement on your own. The only thing you need to do is just making out the image and conduct another forward passing. But if you meet any problem, you can post here.

zeroXscorpion7 commented 1 year ago

Hello, I tried to implement the average drop and increase calculation by myself, but I found that the calculation result does not match with the paper, how can I fix it?

Here is my code, mask is explanation map, image is picture, net is CNN model, ind is the number of class, and tar is the model output of the original drawing in the ind class: mask_c=np.zeros((224,224)) K=int(-0.5*np.size(mask)) MK=np.argpartition(mask.flatten(),K)[K:] mask_c[MK//mask_c.shape[0],MK%mask_c.shape[0]]=1 means=np.zeros(3) im_D=image.copy() im_D[mask_c==0,:]=means inputs=prepare_input(im_D).to(device) output=net(inputs) D=1-output[0][ind].cpu().data.numpy()/tar I=0 if D<0: I=1 Dn=np.maximum(D,0)

I don't know if my understanding is wrong, can you please check how to fix it if you can?

Code-Zark commented 10 months ago

您好,可以提供一下Average Increase Drop和其他指标的评估代码吗,在下感激不尽。!!!!!!

Code-Zark commented 10 months ago

您好,我尝试自己实现平均下降和上升计算,但发现计算结果与论文不符,请问如何修复?

这是我的代码,mask是解释图,image是图片,net是CNN模型,ind是类号,tar是ind类中原图的模型输出:mask_c=np.zeros((224,224 ) ) K=int(-0.5*np.size(mask)) MK=np.argpartition(mask.flatten(),K)[K:] mask_c[MK//mask_c.shape[0],MK%mask_c.shape [0]]=1 意味着=np.zeros(3) im_D=image.copy() im_D[mask_c==0,:]=意味着 输入=prepare_input(im_D).to(device) 输出=net(输入) D =1-输出[0][ind].cpu().data.numpy()/tar I=0 如果 D<0: I=1 Dn=np.maximum(D,0)

不知道我的理解是否有误,如果可以请您检查一下如何解决?

您好,请问您解决了吗,想和您沟通交流一下