ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)

前端 未结 6 1479
闹比i
闹比i 2020-11-27 19:23

I have a list say, temp_list with following properties :

len(temp_list) = 9260  
temp_list[0].shape = (224,224,3)  

Now, when I am conver

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 20:07

    I was facing the same problem because some of the images are grey scale images in my data set, so i solve my problem by doing this

        from PIL import Image
        img = Image.open('my_image.jpg').convert('RGB')
        # a line from my program
        positive_images_array = np.array([np.array(Image.open(img).convert('RGB').resize((150, 150), Image.ANTIALIAS)) for img in images_in_yes_directory])
    

提交回复
热议问题