Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I invoke AWS SageMaker endpoint to get inferences?

I want to get real time predictions using my machine learning model with the help of SageMaker. I want to directly get inferences on my website. How can I use the deployed model for predictions?

like image 980
ashish jangir Avatar asked Nov 21 '18 04:11

ashish jangir


2 Answers

Sagemaker endpoints are not publicly exposed to the Internet. So, you'll need some way of creating a public HTTP endpoint that can route requests to your Sagemaker endpoint. One way you can do this is with an AWS Lambda function fronted by API gateway.

I created an example web app that takes webcam images and passes them on to a Sagemaker endpoint for classification. This uses the API Gateway -> Lambda -> Sagemaker endpoint strategy that I described above. You can see the whole example, including instructions for how to set up the Lambda (and the code to put in the lambda) at this GitHub repository: https://github.com/gabehollombe-aws/webcam-sagemaker-inference/

like image 112
Gabe Hollombe Avatar answered Sep 25 '22 21:09

Gabe Hollombe


You can invoke the SageMaker endpoint using API Gateway or Lambda.

Lambda:

Use sagemaker aws sdk and invoke the endpoint with lambda.

API Gateway:

Use API Gateway and pass parameters to the endpoint with AWS service proxy.

Documentation with example:

https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/

Hope it helps.

like image 45
Kannaiyan Avatar answered Sep 22 '22 21:09

Kannaiyan