# Aws sagemaker deployed model that takes an image at endpoint

**URL:** <https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486>\
**Category:** Inference Endpoints on the Hub\
**Created:** [June 25, 2023, 2:14pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486 "2023-06-25T14:14:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anujyadav140](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/anujyadav140/32/17091_2.png) [@anujyadav140](https://discuss.huggingface.co/u/anujyadav140)\
**Post date:** [June 25, 2023, 2:14pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486/1 "2023-06-25T14:14:37Z")

</div>

so i have deployed the “Salesforce/blip-image-captioning-base” model on aws sagemaker, i am having trouble with the last part, i don’t know what should be the request format for the json so that i can get the response from the api endpoint on sagemaker.

```auto
data = {
    "inputs": {
        "image": "https://images.unsplash.com/photo-1481349518771-20055b2a7b24?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8NHx8cmFuZG9tfGVufDB8fDB8fHww&w=1000&q=80"
    }
}

predictor.predict(data)

```

this is what i am executing and i am getting this exception:

> ModelError Traceback (most recent call last)  
> in   
> 5 }  
> 6  
> ----\> 7 predictor.predict(data)
> 
> /opt/conda/lib/python3.7/site-packages/sagemaker/base\_predictor.py in predict(self, data, initial\_args, target\_model, target\_variant, inference\_id)  
> 165 data, initial\_args, target\_model, target\_variant, inference\_id  
> 166 )  
> → 167 response = self.sagemaker\_session.sagemaker\_runtime\_client.invoke\_endpoint(\*\*request\_args)  
> 168 return self.\_handle\_response(response)  
> 169
> 
> /opt/conda/lib/python3.7/site-packages/botocore/client.py in \_api\_call(self, \*args, \*\*kwargs)  
> 528 )  
> 529 # The “self” in this scope is referring to the BaseClient.  
> → 530 return self.\_make\_api\_call(operation\_name, kwargs)  
> 531  
> 532 \_api\_call. **name** = str(py\_operation\_name)
> 
> /opt/conda/lib/python3.7/site-packages/botocore/client.py in \_make\_api\_call(self, operation\_name, api\_params)  
> 962 error\_code = parsed\_response.get(“Error”, {}).get(“Code”)  
> 963 error\_class = self.exceptions.from\_code(error\_code)  
> → 964 raise error\_class(parsed\_response, operation\_name)  
> 965 else:  
> 966 return parsed\_response
> 
> ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{  
> “code”: 400,  
> “type”: “InternalServerException”,  
> “message”: “Incorrect format used for image. Should be an url linking to an image, a local path, or a PIL image.”  
> }

---

<div class="post-metadata">

**Author:** ![anujyadav140](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/anujyadav140/32/17091_2.png) [@anujyadav140](https://discuss.huggingface.co/u/anujyadav140)\
**Post date:** [June 25, 2023, 2:38pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486/2 "2023-06-25T14:38:17Z")

</div>

if run this code instead:

```auto
predictor.predict({
    "inputs":"https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg",
})

```

i get this error instead:

> ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{  
> “code”: 400,  
> “type”: “InternalServerException”,  
> “message”: “\u0027NoneType\u0027 object is not callable”  
> }

does anyone have any idea how to deal with endpoints that require images in huggingface models?

---

<div class="post-metadata">

**Author:** ![bennett-diaz](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bennett-diaz/32/17713_2.png) [@bennett-diaz](https://discuss.huggingface.co/u/bennett-diaz)\
**Post date:** [July 18, 2023, 2:02pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486/3 "2023-07-18T14:02:55Z")

</div>

Did you ever find a solution to this? I am running into the same issue.

---

<div class="post-metadata">

**Author:** ![anujyadav140](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/anujyadav140/32/17091_2.png) [@anujyadav140](https://discuss.huggingface.co/u/anujyadav140)\
**Post date:** [July 18, 2023, 2:14pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486/4 "2023-07-18T14:14:49Z")

</div>

Hello, yes - the solution was found here:

> **[Salesforce/blip-image-captioning-base · Input for calling predictor.predict()...](https://huggingface.co/Salesforce/blip-image-captioning-base/discussions/19)**
>
> Hi would like to call predictor.predict() on Sagemaker but I haven't been able to figure out or find how the input should be structured. Is there anyone who could provide me with an example?

---

<div class="post-metadata">

**Author:** ![afromobile](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/afromobile/32/22069_2.png) [@afromobile](https://discuss.huggingface.co/u/afromobile)\
**Post date:** [February 14, 2024, 11:38pm UTC](https://discuss.huggingface.co/t/aws-sagemaker-deployed-model-that-takes-an-image-at-endpoint/44486/5 "2024-02-14T23:38:22Z")

</div>

did anyone ever figure out how to make the endpoint work?
