File size: 409 Bytes
347fd60 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from PIL import Image
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.applications import inception_resnet_v2
import numpy as np
def preprocess_image(image):
img = Image.open(image)
# converting image to array
x = img.resize((299, 299))
x = img_to_array(x)
# reshaping the image
x = np.expand_dims(x, axis=0)
return inception_resnet_v2.preprocess_input(x)
|