gradcam_plus_plus-pytorch icon indicating copy to clipboard operation
gradcam_plus_plus-pytorch copied to clipboard

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Open mikbuch opened this issue 1 year ago • 3 comments

Current versions of modules (January 2024).

mikbuch avatar Feb 01 '24 19:02 mikbuch

In utils add:

    heatmap = cv2.applyColorMap(np.uint8(255 * mask.cpu().squeeze()), cv2.COLORMAP_JET)

Line 15

mikbuch avatar Feb 01 '24 19:02 mikbuch

Then it will work

mikbuch avatar Feb 01 '24 19:02 mikbuch

I re-created the repository, indent to modify it further: https://github.com/mikbuch/gradcam-pytorch-pet. Thank you Konny for creating this very useful example.

mikbuch avatar Feb 01 '24 21:02 mikbuch