in src/lambda-inference/app.py [0:0]
def load_img(image_object):
"""
Load image from Amazon S3 bucket and processed it.
"""
max_dim = 512
img = tf.keras.preprocessing.image.img_to_array(image_object)
img = tf.convert_to_tensor(img, dtype=tf.float32)
shape = tf.cast(tf.shape(img)[:-1], tf.float32)
long_dim = max(shape)
scale = max_dim / long_dim
new_shape = tf.cast(shape * scale, tf.int32)
img = tf.image.resize(img, new_shape)
img = img[tf.newaxis, :] / 255
return img