pytorch / captum

Model interpretability and understanding for PyTorch
https://captum.ai
BSD 3-Clause "New" or "Revised" License
4.81k stars 488 forks source link

An issue with function "visualize_image_attr()" #1163

Closed Bubble-Sword closed 1 year ago

Bubble-Sword commented 1 year ago

🐛 Bug

I run the tutorial at "https://captum.ai/tutorials/Segmentation_Interpret" through Google Colab

When proceeding to In [12]:

image

an error is reported

image

And then I check the source code of "visualization.py" on the git hub, the code at line 250 is:

image

To Reproduce

Steps to reproduce the behavior:

  1. run the notebook download from "https://captum.ai/tutorials/Segmentation_Interpret"

Expected behavior

the ndarray can be visualized

Environment

Google Colab Python 3.10.12 Pytorch 2.0.1+cu118

install with: !pip install captum



 - Captum / PyTorch Version (e.g., 1.0 / 0.4.0):
 - OS (e.g., Linux):
 - How you installed Captum / PyTorch (`conda`, `pip`, source):
 - Build command you used (if compiling from source):
 - Python version:
 - CUDA/cuDNN version:
 - GPU models and configuration:
 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->
kainat-altaf-cau commented 1 year ago

I am facing the same issue.

vivekmig commented 1 year ago

Hi @Bubble-Sword and @kainat-altaf-cau , we have fixed this issue in #1118 , but this fix is not yet in a release package. In the meantime, you can install Captum from source (master) as follows to avoid this issue:

pip install git+https://github.com/pytorch/captum.git