in api/ImageSimilarity/deployment/app.py [0:0]
def preprocessInputBatch(img_array):
'''
This method will pre-process the batch of images by running it through the ResNet50 model. The output is the 2048 vector representations for each image
'''
global keras_model
global img_width
global img_height
global graph
#need to re-order the images to be the correct format (n, img_width, img_height, 3)
imgs = []
for img in img_array:
img = np.array(img.resize((img_width,img_height)))
imgs.append(img)
imgs = np.array(imgs).astype(np.float)
with graph.as_default():
X = preprocess_input(imgs)
X = keras_model.predict(X)
return X