Skip to content

Official OcclusionSensitivity example is not workable #183

@bbb801

Description

@bbb801

Dear Sir,

The example of OcclusionSensitivity in your example is not workable(https://docs.monai.io/en/latest/visualize.html?highlight=OcclusionSensitivity).

Run:

densenet 3d

from monai.networks.nets import DenseNet
from monai.visualize import OcclusionSensitivity

model_3d = DenseNet(spatial_dims=3, in_channels=1, out_channels=3, init_features=2, growth_rate=2, block_config=(6,))
occ_sens = OcclusionSensitivity(nn_module=model_3d, n_batch=10, stride=2)
occ_map, most_probable_class = occ_sens(torch.rand(1, 1, 6, 6, 6), class_idx=1, b_box=[-1, -1, 2, 3, -1, -1, -1, -1])

Error:


TypeError Traceback (most recent call last)
in
5 model_3d = DenseNet(spatial_dims=3, in_channels=1, out_channels=3, init_features=2, growth_rate=2, block_config=(6,))
6 occ_sens = OcclusionSensitivity(nn_module=model_3d, n_batch=10, stride=2)
----> 7 occ_map, most_probable_class = occ_sens(torch.rand(1, 1, 6, 6, 6), class_idx=1, b_box=[-1, -1, 2, 3, -1, -1, -1, -1])

TypeError: call() got an unexpected keyword argument 'class_idx'

When I deleted 'class_idx', I still had an error:


ValueError Traceback (most recent call last)
in
5 model_3d = DenseNet(spatial_dims=3, in_channels=1, out_channels=3, init_features=2, growth_rate=2, block_config=(6,))
6 occ_sens = OcclusionSensitivity(nn_module=model_3d, n_batch=10, stride=2)
----> 7 occ_map, most_probable_class = occ_sens(torch.rand(1, 1, 6, 6, 6), b_box=[-1, -1, 2, 3, -1, -1, -1, -1])

/environment/python/versions/miniconda3-4.7.12/lib/python3.7/site-packages/monai/visualize/occlusion_sensitivity.py in call(self, x, b_box)
297
298 # Generate sensitivity images
--> 299 sensitivity_ims_list, output_im_shape = self._compute_occlusion_sensitivity(x, b_box)
300
301 # Loop over image for each classification

/environment/python/versions/miniconda3-4.7.12/lib/python3.7/site-packages/monai/visualize/occlusion_sensitivity.py in _compute_occlusion_sensitivity(self, x, b_box)
218 raise ValueError(
219 "Stride and mask size should both be odd or even (element-wise). "
--> 220 + f"stride={self.stride}, mask_size={self.mask_size}"
221 )
222

ValueError: Stride and mask size should both be odd or even (element-wise). stride=[1 2 2 2], mask_size=[ 1 15 15 15]

I have used the corresponding version Monai.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions