Matplotlib 尝试分割图像颜色时出错:numpy.ndarray';对象没有属性';面具';
这是我的python代码:Matplotlib 尝试分割图像颜色时出错:numpy.ndarray';对象没有属性';面具';,matplotlib,tensorflow,keras,image-recognition,Matplotlib,Tensorflow,Keras,Image Recognition,这是我的python代码: 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
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])
这就是返回的错误
文件“/Users/mcarvalho/PycharmProjects/SimpleImageRecognition/venv/lib/python3.6/site packages/matplotlib/image.py”,第419行,在“make_image”中
如果A.mask.shape==A.shape:
AttributeError:'numpy.ndarray'对象没有属性'mask'
matplotlib中确实存在一个bug。您可以将matplotlib降级到2.0.0版,然后它就可以工作了。至少对我有用。要降级matplotlib,必须运行
pip install --upgrade --force-reinstall matplotlib==2.0.0
希望它能帮助你 在matplotlib 2.2.2中似乎也被固定:
sudo pip3 install matplotlib --upgrade
将numpy和matplot lib更新到最新版本后,我也遇到了同样的问题。但是,我不知道那里发生了什么。。。