gogoWebsite

ValueError: cannot reshape array of size xxx into shape (xxx,xxx,xxx)cure

Updated to 6 months ago

Report an error:

ValueError: cannot reshape array of size 149184 into shape (28,28,1)

Reason for reporting error:

Caused by multiplying the w, h, c of the image equal to 149184. Unable to reshape array of size 149184 into shape (28,28,1)

Solution:

I entered the image shape as (224, 222, 3) so 224 * 222 * 3 = 149184

Changing the size of an image via opencv

	#resize the size of the image First, we will change the original (224,222,3) ----> (28,28,3)
    pred_img = cv2.resize(pred_img,(28,28))                          
    # Convert np array format
    pred_img = np.array(pred_img)   
    #Reshape the picture
    pred_img = pred_img.reshape(-1,28,28,1)
    #View the image shape after reshape
    print(pred_img.shape)








😍😍😍

If this article is helpful you may want to like and click ➕Follow!