this one helps. In the second script, the use of glob creates a list of tiff files that are unordered. For this approach to work, you need an ordered list of tiff files (e.g. [00001.tif, 00002.tif, ... 1234.tif]) that can be associated with the ordered predictions. The sorted() function can be used to do the ordering.
Does that help The error looks to be coming from a GRPC client closing the connection before the server is able to respond. (There looks to be an existing feature request for the sagemaker tensorflow container on https://github.com/aws/sagemaker-tensorflow-container/issues/46 to make this timeout configurable) You could try out a few things with the sagemaker Transformer to limit the size of each individual request so that it fits within the timeout:
how can I preprocess input data before making predictions in sagemaker?
import numpy as np
from PIL import Image
from keras.applications.resnet50 import preprocess_input
from keras.preprocessing import image
JPEG_CONTENT_TYPE = 'image/jpeg'
# Deserialize the Invoke request body into an object we can perform prediction on
def input_fn(request_body, content_type=JPEG_CONTENT_TYPE):
# process an image uploaded to the endpoint
if content_type == JPEG_CONTENT_TYPE:
img = Image.open(io.BytesIO(request_body)).resize((300, 300))
img_array = np.array(img)
expanded_img_array = np.expand_dims(img_array, axis=0)
x = preprocess_input(expanded_img_array)