sicara / tf-explain

Interpretability Methods for tf.keras models with Tensorflow 2.x
https://tf-explain.readthedocs.io
MIT License
1.02k stars 110 forks source link

Heatmap display fails with rescaled image #95

Closed transcranial closed 4 years ago

transcranial commented 5 years ago

In the heatmap_display function, original_image is assumed to be [0, 255]. For GradCAM, when running explain, the original image is passed to the model as well as heatmap_display. However, if the model takes a rescaled input, such as [0, 1], then the output will not display the image since it's using the rescaled image.

In the GradCAM example, change this line to:

img = tf.keras.preprocessing.image.img_to_array(img) / 255

and observe the output.

RaphaelMeudec commented 4 years ago

@transcranial Just merged a patch for this on master, should be good.

rao208 commented 4 years ago

@RaphaelMeudec Could you please tell me what does this mean? I am using tensorflow 2.1.

I still can't see the heatmap when the image is rescaled. I have a python file in which I do import tf_explain and Occlusion sensitivity callback.