Hi All,
I'm running
!python test.py --model test --dataroot datasets/Pixabay_pretest_190517_vangogh --model_suffix _A --preprocess none --no_dropout --load_size 1920 --crop_size 1920 --display_winsize 1920
based on the pretrained style_vangogh. But the following error occurs:
Traceback (most recent call last):
File "test.py", line 33, in
from util.visualizer import save_images
File "/content/drive/pytorch-CycleGAN/util/visualizer.py", line 8, in
from scipy.misc import imresize
ImportError: cannot import name 'imresize'
I'm running on Google Colab where scipy's version is 1.3.0. According to official document, 'imresize' is removed in SciPy 1.3.0.
https://docs.scipy.org/doc/scipy-1.2.0/reference/generated/scipy.misc.imresize.html
The document suggests using Pillow:
Use Pillow instead: numpy.array(Image.fromarray(arr).resize()).
But I'm not sure how to modify the code. Could you please help me fix it? Thank you!
@junyanz
Dr. Zhu, I admire all your great work. May I add your QQ please?
Amber Ji
the im in visualizer.py is a numpy array, so if you load that into a PIL image by Image.fromarray(im) and then call .resize((h, int(w * aspect_ratio)), resample=PIL.Image.BICUBIC) on it, it should work as before. I haven't try it tho because i just downgraded my scipy to 1.2.1...
@ethanyanjiali Thanks Ethan. I will try your idea.
@ethanyanjiali I changed the code in the way you suggested and it works.
# im = imresize(im, (h, int(w * aspect_ratio)), interp='bicubic')
im = np.array(Image.fromarray(im).resize((h, int(w * aspect_ratio))))
@ethanyanjiali
thank you for the syntax which works but for me,
I am getting this error
NameError: global name 'Image' is not defined
how can this be corrected
@sanket-p
First:
pip install Pillow
Then:
from PIL import Image
Most helpful comment
@ethanyanjiali I changed the code in the way you suggested and it works.