I am a beginner to machine learning, so I was trying to create a model for recognizing images referenced from Keras blog. I have installed Anaconda 3 on windows 10 and all the packages like tensorflow, keras, scipy, numpy, pandas
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
datagen = ImageDataGenerator(
rotation_range=40,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest')
img = load_img('E:/ML_R&D/training_set/cats/cat.3919.jpg') # this Line is giving me error
I am using conda command and pillow using pip, but when I run a code taken from keras blog I got the error.
The use of `array_to_img` requires PIL - Jetson Nano - NVIDIA Developer Forums Could not import PIL.Image. The use of `array_to_img` requires PIL
The use of load_img requires PIL #444 ImportError: Could not import PIL.Image. The use of load_img requires PIL. I am running on MacOS 11.0.1 with the Apple TensorFlow backend. My reticulate::py_config () returns the following result:
0 StopIteration: Could not import PIL.Image. The use of `array_to_img` requires PIL error 2 Not able to print correct confusion matrix and also in heatmap values are printing in example 2e+2, e+4 etc etc
You will want to install the PIL package.
How do I install PIL/Pillow for Python 3.6?
pip install pillow
or
pip3 install pillow
the issue is solved, may be the problem was that I did not restarted my system after adding all the libraries. This issue can be closed.
Step 1: Firstly make sure that the PIL is uninstalled as PIL and pillow cannot co-exist. For this open Anaconda Powershell Prompt and type
pip uninstall pillow
Then press y(yes) when asked.
If you do not have pillow or PIL then proceed to step 2
Step 2: In the same powershell prompt, execute
pip install pillow
Step 3: After the installation, close the jupyter notebook, anaconda, and restart your system.
Step 4: Now execute
from keras.preprocessing.image import load_image
.
IT WILL WORK !!!
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