pan-card-classifier / api /preprocess.py
shailgsits's picture
Upload folder using huggingface_hub
f0e10d7 verified
Raw
History Blame Contribute Delete
311 Bytes
from PIL import Image
import numpy as np
IMAGE_SIZE = (224, 224)
def preprocess_image(image: Image.Image):
image = image.convert("RGB")
image = image.resize(IMAGE_SIZE)
image = np.asarray(image).astype("float32")
image /= 255.0
image = np.expand_dims(image, axis=0)
return image