Open vk-mittal14 opened 4 years ago
That's because imresize has been removed from scipy since v1.3.0rc1 What you can do is edit the code in vis/visualization/saliency.py to use other function to resize, such as opencv resize.
Or, As being mentioned in https://github.com/raghakot/keras-vis/issues/203#issuecomment-565582881 , you can downgrade scipy to 1.1.0 as follows:
pip install scipy==1.1.0
as @Mazzanicolas said:
in vis/visualization/saliency.py
replace: from scipy.misc import imresize
to: import cv2
then
replace: heatmap = imresize(heatmap, input_dims, interp='bicubic', mode='F')
to:
heatmap = cv2.resize(src=heatmap,
dsize=input_dims,
interpolation=cv2.INTER_CUBIC)
I just couldn't map the mode
param.
Another way of solving this (I did it myself and it's working quite well) is to use Pillow library:
in vis/visualization/saliency.py
comment from scipy.misc import imresize
and add from PIL import Image
comment heatmap = imresize(heatmap, input_dims, interp='bicubic', mode='F')
Then, update the heatmap
variable as such:
heatmap = np.array(Image.fromarray(obj=heatmap, mode='F').resize(size=input_dims, resample=Image.BICUBIC))
Check SciPy: scipy.misc.imresize
And Pillow: Pillow Image Module
Or, As being mentioned in #203 (comment) , you can downgrade scipy to 1.1.0 as follows:
pip install scipy==1.1.0 ```It worked for me :)
Check docs: scipy.misc.imresize - SciPy v1.2.1 Reference Guide imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
Check example: sample problem
If you are using scipy version earlier than 1.3.0, then try this (it worked for me, tested on version 0.19.1):
instead of:
... from scipy.misc import imresize ...
imresize()
do:
... from scipy import misc ...
misc.imresize()
While importing
visualize_activation
fromvis.visualization
I got this errorfrom vis.visualization import visualize_activation