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

python 3.x-得到错误“无法导入PIL.Image。使用array_to_img需要PIL。”

(python 3.x - Getting error "Could not import PIL.Image. The use of `array_to_img` requires PIL.")

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

我是机器学习的初学者,因此我想创建一个模型来识别Keras博客引用的图像。我已经在Windows 10上安装了Anaconda 3并安装了所有软件包,例如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

我正在使用conda命令,并使用pip枕头,但是当我运行来自keras博客的代码时,出现了错误。

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

问题已解决,可能是问题是我在添加所有库后没有重新启动系统。此问题可以解决。