this is my code,I want to use it in segformer, so i add the reshape_transform:
analysis_tools/visualization_cam.py:
with GradCAM(
model=model,
target_layers=target_layers,
use_cuda=torch.cuda.is_available(),
reshape_transform=reshape_transform) as cam:
grayscale_cam = cam(input_tensor=input_tensor, targets=targets)[0, :]
cam_image = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
but it does not work,occur below:
An exception occurred in CAM with block: <class 'numpy.AxisError'>. Message: axis 2 is out of bounds for array of dimension 0
this is my code,I want to use it in segformer, so i add the reshape_transform:
analysis_tools/visualization_cam.py:
but it does not work,occur below: An exception occurred in CAM with block: <class 'numpy.AxisError'>. Message: axis 2 is out of bounds for array of dimension 0