2

I have some data in S3 and I want to create a lambda function to predict the output with my deployed aws sagemaker endpoint then I put the outputs in S3 again. Is it necessary in this case to create an api gateway like decribed in this link ? and in the lambda function what I have to put. I expect to put (where to find the data, how to invoke the endpoint, where to put the data)

Thanks

1 Answer 1

4

you definitely don't have to create an API in API Gateway. You can invoke the endpoint directly using the invoke_endpoint() API, passing the endpoint name, the content type, and the payload.

For example:

import boto3

endpoint_name = <INSERT_ENDPOINT_NAME>
runtime = boto3.Session().client(service_name='sagemaker-runtime',region_name='us-east-1')

response = runtime.invoke_endpoint(EndpointName=endpoint_name, ContentType='application/x-image', Body=payload)
print(response['Body'].read())

More examples here using a Lambda function: https://medium.com/@julsimon/using-chalice-to-serve-sagemaker-predictions-a2015c02b033

Sign up to request clarification or add additional context in comments.

2 Comments

thank you for your response but that's not exactly my problem can you please see this new issue which more clarify my issue thank you
@Julien Simon, Could you please have a look at stackoverflow.com/questions/59379081/… and let know what's going on wrong here. I believe it has to do with JSON request format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.