1 個回答
- 最新
- 最多得票
- 最多評論
0
import json
import io
import boto3
client = boto3.Session().client(service_name='sagemaker-runtime',region_name='us-east-1')
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
#data = json.loads(json.dumps(event))
#payload = data['data']
#print(payload)
response = client.invoke_endpoint(EndpointName='linear-learner-2019-12-12-16-20-56-788',
ContentType='application/json',
Body= json.dumps(event))
print(response)
result = response['Body']
res = result.read()
res = json.loads(res)
print(res)
print(res['predictions'][0])
The error was in the response format and on how to read them. Above code resolve the issue.
已回答 4 年前
相關內容
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前