2017-12-27 12 views
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'

+0

numpyとmatplotのlibを最近のバージョンにアップデートした後も同じ問題があります。それでも、何が起こっているのか分かりません... – Dmytro

答えて

1

を返さmatplotlibでmatplotlibをバージョン2.0.0にダウングレードすると、動作します。少なくともそれは私のために働く。 matplotlibをダウングレードするには実行する必要があります

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

希望すると助かります!

関連する問題