I have the following code
from keras.preprocessing import image
test_image = image.load_img('roi.jpg', target_size = (64, 64),grayscale=True)
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis = 0)
The roi.jpg is an image which saved in the same directory. After execution I got the following error
test_image = image.load_img('roi.jpg', target_size = (64, 64),grayscale=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\preprocessing\image.py", line 345, in load_img raise ImportError('Could not import PIL.Image. ')
ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL.
Please help me to solve this error. I have used windows 10
and python version : Python 3.6.3 :: Anaconda custom (64-bit)
You need the PIL module, try the first one else try the second one
conda install PIL
conda install Pillow
or if both PIL and Pillow exists, uninstall both and re-install PIL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With