-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问grad cam对于单通道图片输入应该办呢 #71
Comments
十分感谢您的回复 1.我把这个注释之后确实不报错了,但是结果应该不对,显示的结果是纯的淡紫色,根本看不出东西。其实在报这个错误之前还报过一个错误,然后我把cam_weights = np.mean(g, (2, 3), keepdims=True)改成了cam_weights = np.mean(g, axis=2, keepdims=True),我看了一下是因为返回的梯度是一个三维的,不是四维的,deeplabv3+返回的就是四维的,我的网络是segformer。
|
PS 另外基于patch作为token的transformer模型,不确定效果 |
好的好的,我先试一下,如果你需要我这的模型和数据的话,我可以邮箱发给你,我的邮箱是[email protected], 十分感谢 |
GradCAM是能复现的,效果看着也正常,inputgrad_segmentaton复现不了,会报我上面给的那个错误 |
这个我这边能正常跑,跑出的结果和链接中的区别不大。 我把deeplabv3改成了单通道的,然后跑了一下,可以看下这个:https://github.com/PaddlePaddle/InterpretDL/blob/master/tutorials/InputGrad_Segmentation_for_one_channel.ipynb |
1.图片红框里面的两个模型路径可以都写自己训练好的模型吗 2.我怎么知道可视化的是哪个层的呢,这个代码表示可视化的目标层吗,跟gradcam的代码不太一样,
|
还有个问题是为什么segformer产生的gradients是三维[1, 256, 512]的,而deeplabv3+产生的gradients是四维[1, 2048, 64, 64]的呢 |
我使用grad cam做语义分割的可解释性,我训练好的模型也是单通道训练的,我是用gradcam的时候也是单通道,会报下面这个错误,请问我该怎么修改呢
AssertionError Traceback (most recent call last)
/tmp/ipykernel_2663/1576993860.py in
4 pixels = [(30, 30)]
5 # good layers for deeplabv3p: backbone.bb_3_2.relu, head.aspp, head.decoder.conv
----> 6 exp = gradcam.interpret(img_path, pixels, target_layer_name='backbone.norm4', resize_to=512, crop_to=512)
/tmp/ipykernel_2663/3928282195.py in interpret(self, inputs, pixels, labels, target_layer_name, gradient_of, resize_to, crop_to, visual, save_path)
217 vis_explanation = explanation_to_vis(imgs[i],
218 gradcam_explanation[i],
--> 219 style='overlay_heatmap')
220 if visual:
221 show_vis_explanation(vis_explanation)
~/.data/webide/pip/lib/python3.7/site-packages/interpretdl/data_processor/visualizer.py in explanation_to_vis(batched_image, explanation, style)
51 assert len(batched_image.shape) == 3
52
---> 53 assert len(explanation.shape) == 2, f"image shape {batched_image.shape} vs "
54 f"explanation {explanation.shape}"
55
AssertionError: image shape (512, 512, 3) vs explanation (512,)
The text was updated successfully, but these errors were encountered: