Warm tip: This article is reproduced from serverfault.com, please click

Getting error "Could not import PIL.Image. The use of `array_to_img` requires PIL."

发布于 2018-07-23 12:59:54

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.

Questioner
Rahul
Viewed
0
Rahul 2018-07-24 21:18:06

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.