Skip to content

请问grad cam对于单通道图片输入应该办呢 #71

Description

@wanghonen

我使用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,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions