小编Mau*_*lho的帖子

尝试分割图像颜色时出错:numpy.ndarray'对象没有属性'mask'

这是我的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 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])
Run Code Online (Sandbox Code Playgroud)

这就是返回的错误

文件“/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 image-recognition keras tensorflow

3
推荐指数
1
解决办法
4226
查看次数

标签 统计

image-recognition ×1

keras ×1

matplotlib ×1

tensorflow ×1