PAIR-code / saliency

Framework-agnostic implementation for state-of-the-art saliency methods (XRAI, BlurIG, SmoothGrad, and more).
https://pair-code.github.io/saliency/
Apache License 2.0
950 stars 191 forks source link

Enable half_pixel_centers=True for resizing GradCAM heatmap. #50

Closed amitani closed 3 years ago

amitani commented 3 years ago

Enable half_pixel_centers=True for resizing after GradCAM to avoid shift by a half pixel.

It will make the behavior compatible to tf.image.resize in tf2. See https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/ops/image_ops_impl.py#L1623

Alternatively, this is equivalent to changing tf.image.resize_bilinear to tf.compat.v2.image.resize, or to tf.image.resize and change tf import to v2.

Note that only changing this to tf.image.resize won't solve the bug, because in tf1, it doesn't enable half_pixel_centers. https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/ops/image_ops_impl.py#L1447

bwedin commented 3 years ago

Closed since we are now using skimage.transform.resize.