sagemaker-python-sdk icon indicating copy to clipboard operation
sagemaker-python-sdk copied to clipboard

Error decoding a response from invoking a sageMaker endpoint

Open desmanda opened this issue 6 years ago • 8 comments

I am invoking a sageMaker endpoint that returns an image from a tensorflow model using thecode below. I got a 200 response but I can't parse the predictions, the decoding of the response is throwing the following error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 23: invalid start byte This is my actual code:

pose_array = np.empty([16,3])
images = [{"b64": read_from_url(url)} for url in urls]
input_data = [{''keypoints': pose_array, 'images':  list_of_images}]
body = json.dumps({"signature_name": "serving_default", "instances": input_data})
response = client.invoke_endpoint(
        EndpointName=endpoint_name,
        ContentType=''application/json',
        Body=body,
        Accept='Accept')
response = response.get("Body").read().decode()

the response can't be decoded, so I can't get the predictions

desmanda avatar Jan 15 '20 22:01 desmanda

Also been hitting this issue.

Is your container in python 2.7?

moviedatascience avatar Jan 15 '20 23:01 moviedatascience

no, I am using python 3.6

desmanda avatar Jan 16 '20 09:01 desmanda

Hey guys, I am having the same issue. Any resolution? Thanks.

raptorsdigital avatar Jun 13 '20 19:06 raptorsdigital

I have the similar issue. I tried both Python 3.6 and 3.8, response['Body'].read().decode() doesn't include any prediction score.

pdkang avatar Oct 30 '20 23:10 pdkang

I am having the same issue: data = serialized_input_data.decode('utf-8') AttributeError: 'str' object has no attribute 'decode'

xxl4tomxu98 avatar Aug 10 '21 13:08 xxl4tomxu98

Moving this issue to the SageMaker Python SDK repository because it isn't associated with an example notebook.

jkroll-aws avatar Aug 10 '21 20:08 jkroll-aws

hello, this looks like a boto3 issue not a sagemaker sdk issue. I would recommend opening an issue with the boto3 codebase here

BasilBeirouti avatar Sep 09 '21 23:09 BasilBeirouti

Closing as should be transferred to boto3. Thank you!

martinRenou avatar Sep 28 '23 11:09 martinRenou