Image comes from the front end in PIL I preprocess it but it giving me a different shape than expected.
my code is
def preprocess(img):
img = np.array(img)
resized = cv2.resize(img, (254, 254))
img = tf.keras.preprocessing.image.img_to_array(resized)/255
img = np.array([img])
return img
this is a pil image
<PIL.JpegImagePlugin.JpegImageFile image mode=L size=2144x1805 at 0x229615E2488>
And when I preprocess it, it gives this shape
the shape of the test image is (1, 254, 254, 1)
and when I try the preprocess code outside of my project it works fine.