error: (-215) ssize.width > 0 && ssize.height > 0 in function resize

前端 未结 6 1793
借酒劲吻你
借酒劲吻你 2020-12-10 07:09

I am building an image processing classifier. This line is giving me an error:

input_img_resize=cv2.resize(input_img,(128,128))

The error:

6条回答
  •  眼角桃花
    2020-12-10 07:25

    If you are working with several images (for example, 1000 images), it may be difficult for you to identify which image is giving you problems. It may also be that, there are several others that are corrupt. In such a case, the code below can be useful.

    for file in filenames:
        try:
            image = cv2.resize(cv2.imread(file), (size, size))
        except:
            print(file)
    

    where filenames is a list which contains names of the images.

提交回复
热议问题