使用 lambda 函数调用 sagemaker 端点 [英] call sagemaker endpoint using lambda function

查看:28
本文介绍了使用 lambda 函数调用 sagemaker 端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 S3 中有一些数据,我想创建一个 lambda 函数来预测我部署的 aws sagemaker 端点的输出,然后我再次将输出放入 S3.在这种情况下是否有必要创建一个 api 网关,如此 link ?在 lambda 函数中我必须放什么.我期望放(在哪里可以找到数据,如何调用端点,在哪里放数据)

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)

谢谢

推荐答案

您绝对不必在 API Gateway 中创建 API.您可以使用 invoke_endpoint() API 直接调用端点,传递端点名称、内容类型和有效负载.

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.

例如:

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())

此处使用 Lambda 函数的更多示例:https://medium.com/@julsimon/using-chalice-to-serve-sagemaker-predictions-a2015c02b033

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

这篇关于使用 lambda 函数调用 sagemaker 端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆