Shap: Clipping input data to the valid range for imshow

Created on 17 Jul 2019  Â·  6Comments  Â·  Source: slundberg/shap

I've followed the PyTorch DeepExplainer nb tutorial and made sure that the ranges and dtypes of my lists/arrays match accordingly, but for some reason when calling shap.image_plot I get black images with the warning:

Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).

Here's a screenshot showing the issue and the dtypes/ranges:

Screenshot 2019-07-16 23 44 41

I think the only difference is that I'm using 3 color channel images (RGB).

Most helpful comment

For me what worked is
(img * 255).astype(np.uint8)

All 6 comments

I have the same problem, have you found a solution @austinmw ?

I discovered that for me the issue was that while transforming the data I was normalizing the images (in order to use transfer learning) but this pushed all the pixels towards black. By inverting the normalization within the imshow function I was able to plot the original images.

For me what worked is
(img * 255).astype(np.uint8)

I also got the same problem, how I can solve it?

I discovered that for me the issue was that while transforming the data I was normalizing the images (in order to use transfer learning) but this pushed all the pixels towards black. By inverting the normalization within the imshow function I was able to plot the original images.

Hello, I also did normalize for transfer learning,> I discovered that for me the issue was that while transforming the data I was normalizing the images (in order to use transfer learning) but this pushed all the pixels towards black. By inverting the normalization within the imshow function I was able to plot the original images.

Hello, I also did normalize for transfer learning,did you tell me the detailed code for me to address this problem?

For me what worked is
(img * 255).astype(np.uint8)

Hi! May I know where do I plug this value in? Since the problem occurs at the image_plot() method of shap. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artemmavrin picture artemmavrin  Â·  4Comments

cbeauhilton picture cbeauhilton  Â·  3Comments

gabrielcs picture gabrielcs  Â·  3Comments

DiliSR picture DiliSR  Â·  4Comments

resdntalien picture resdntalien  Â·  3Comments