You can submit inference requests using SageMaker AI SDK for Python (Boto3) client and
invoke_endpoint()
InService
.
The following code example shows how to send an image for inference:
import boto3
import json
endpoint = 'insert name of your endpoint here'
runtime = boto3.Session().client('sagemaker-runtime')
# Read image into memory
with open(image, 'rb') as f:
payload = f.read()
# Send image via InvokeEndpoint API
response = runtime.invoke_endpoint(EndpointName=endpoint, ContentType='application/x-image', Body=payload)
# Unpack response
result = json.loads(response['Body'].read().decode())
Note that BYOM allows for a custom content type. For more information,
see
runtime_InvokeEndpoint
.