gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 21:56:18 25 4
gpt4 key购买 nike

这是我的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])

这是返回的错误

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'

最佳答案

似乎在 matplotlib 2.2.2 中也已修复:

sudo pip3 install matplotlib --upgrade

关于matplotlib - 尝试分割图像颜色时出错 : numpy. ndarray' 对象没有属性 'mask',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47992078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com