I try make predictions with a TensorFlow-Keras model in Sagemaker, but recive the next errors:
In Amazon Cloudwatch, for Lambda Function:
An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (415) from model with message "
{
"error": "Unsupported Media Type: application/x-image"
}
In Cloudwatch, for Sagemaker:
F external/org_tensorflow/tensorflow/core/util/tensor_format.h:426] Check failed: index >= 0 && index < num_total_dims Invalid index from the dimension: 3, 0, C
Data is an image send in base64, the Lambda function convert this img to bytes, Lambda Function is:
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
data = json.loads(json.dumps(event))
payload = data['foto']
image = base64.b64decode(payload)
print(type(image))
try:
response = runtime.invoke_endpoint(EndpointName=ENDPOINT_NAME,
ContentType='application/x-image',
Body=image)
print(response)
except Exception as e:
print("error en inferencia:")
print(e)
return payload # only for test