1
這是我的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'
更新numpy和matplot lib到最新版本後,我有同樣的問題。不過,不知道那裏會發生什麼...... – Dmytro