错误试图分裂图像颜色:numpy.ndarray”对象有没有属性‘面具’

这是我的Python代码:错误试图分裂图像颜色:numpy.ndarray”对象有没有属性‘面具’

from PIL import Image 

labels = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']

from keras.datasets import cifar10

(X_train, Y_train), (X_test,y_test) = cifar10.load_data()

index = int(input('Enter an image index: '))

display_image = X_train[index]

display_label = Y_train[index][0]

from matplotlib import pyplot as plt

red_image = Image.fromarray(display_image)

red,green,blue = red_image.split()

plt.imshow(red, cmap="Reds")

plt.show()

print(labels[display_label])

那是错误返回

File "/Users/mcarvalho/PycharmProjects/SimpleImageRecognition/venv/lib/python3.6/site-packages/matplotlib/image.py", line 419, in _make_image if A.mask.shape == A.shape: AttributeError: 'numpy.ndarray' object has no attribute 'mask'

回答:

确实存在一个bug在matplotlib中。你可以将你的matplotlib降级到版本2.0.0,然后它会工作。至少它适合我。降级matplotlib你必须运行

pip install --upgrade --force-reinstall matplotlib==2.0.0 

希望它会帮助你!

以上是 错误试图分裂图像颜色:numpy.ndarray”对象有没有属性‘面具’ 的全部内容, 来源链接: utcz.com/qa/264990.html

回到顶部