I have an image that I upload to s3 in mybucket. Suppose my s3 endpoint for this data is s3://mybucket/imgname
Now I also have a model deployed in SageMaker at sagemaker-model-endpoint
I looked into examples of how to invoke this SageMaker endpoint from a boto client here but I am not sure how to specify the s3 path s3://mybucket/imgname in the invoke_endpoint call.
client = boto3.client("runtime.sagemaker", region_name = 's3.us-east-2.amazonaws.com')
client.invoke_endpoint(
EndpointName=sagemaker-model-endpoint
Body=payload,
ContentType='image/jpg',
Accept='Accept')
What should be the payload in this case? Where do I specify the s3 url?
You need to have the bytes of the image, and after you get the image from S3 (S3 copy or wget), you can call:
with open(file_name, 'rb') as f:
payload = f.read()
payload = bytearray(payload)
client.invoke_endpoint(EndpointName=sagemaker-model-endpoint,
ContentType='application/x-image',
Body=payload)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With