1Konny / gradcam_plus_plus-pytorch

A Simple pytorch implementation of GradCAM and GradCAM++
357 stars 94 forks source link

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

Open mikbuch opened 8 months ago

mikbuch commented 8 months ago

Current versions of modules (January 2024).

mikbuch commented 8 months ago

In utils add:

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

Line 15

mikbuch commented 8 months ago

Then it will work

mikbuch commented 8 months ago

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.