jagadeesh72's picture
Upload preprocess.py
ce0ac8d verified
raw
history blame contribute delete
324 Bytes
import numpy as np
from PIL import Image
IMG_SIZE = 224 # change if your model uses different size
def preprocess_image(image_path):
img = Image.open(image_path).convert("RGB")
img = img.resize((IMG_SIZE, IMG_SIZE))
img = np.array(img) / 255.0
img = np.expand_dims(img, axis=0)
return img