Обязательный аргумент 'range' (поз. 2) не найден - PullRequest
0 голосов
/ 29 апреля 2020

Я делаю цвет глаз, распознающий нейронную сеть. Мне нужно сделать фотографии RGB, но я получаю эту ошибку:

Обязательный аргумент 'range' (поз. 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

1 Ответ

0 голосов
/ 29 апреля 2020

Я нахожу решение, когда меняю код:

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
...