未找到所需参数'ranges'(pos 2)。

问题描述 投票:-2回答:1

我在做眼睛颜色识别神经网络。我需要把照片做成RGB,但我得到了这个错误。

没有找到所需参数'ranges'(pos 2)。

这是我的代码。

DATADIR = "/content/drive/My Drive/ForpythonEyes"

CATEGORIES = ["BlueEyes", "BrawnEyes"]

for category in CATEGORIES:  # do brawn and blue eyes
    path = os.path.join(DATADIR,category)  # create path to eyes
    for img in os.listdir(path):  # iterate over each image 
        img_array = cv2.cvtColor(cv2.UMat(os.path.join(path,img)), cv2.COLOR_BGR2RGB)  # convert to array
        plt.imshow(img_array,)  # graph it
        plt.show()  # display

        break  
    break

这是完整的错误

TypeError                                 Traceback (most recent call last)
<ipython-input-78-a65ab6652084> in <module>()
     13     path = os.path.join(DATADIR,category)  # create path to dogs and cats
     14     for img in os.listdir(path):  # iterate over each image per dogs and cats
---> 15         img_array = cv2.cvtColor(cv2.UMat(os.path.join(path,img)), cv2.COLOR_BGR2RGB)  # convert to array
     16         plt.imshow(img_array,)  # graph it
     17         plt.show()  # display!

TypeError: Required argument 'ranges' (pos 2) not found
python matplotlib neural-network cv2
1个回答
0
投票

我找到了解决方案,当我改变代码。

for category in CATEGORIES:  # do brawn and blue eyes
    path = os.path.join(DATADIR,category)  # create path to eyes
    for img in os.listdir(path):  # iterate over each image
        img = mpimg.imread(os.path.join(path,img))
        img_array = img  # convert to array
        plt.imshow(img_array)  # graph it
        plt.show()  # display
        break  
    break
© www.soinside.com 2019 - 2024. All rights reserved.