Search code examples
tensorflowresizeopencvimage-classificationpython

I tried simple can & dog image classification in tensorflow and suddenly mess with problem. please could you please help me to solve this?


I got following error when exciting this function, error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-1bq9o88m\opencv\modules\imgproc\src\resize.cpp:4051: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize

for img in os.listdir(folder):
    img_path = os.path.join(folder, img)
    img_arr  = cv2.resize(cv2.imread(img_path), (IMG_SIZE, IMG_SIZE))

Solution

  • What is the shape of you input images and what are the minimum and maximum pixel values. It appears cv2.imread is not reading the image. Try using debug code below:

    for img in os.listdir(folder):
        img_path = os.path.join(folder, img)
        print (img_path)
        try:
            input_img=cv2.imread(img_path)
            img_shape=input_img.shape
            print ( img_shape)
        except:
            print(' image was not read in')