Aws sagemaker deployed model that takes an image at endpoint

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.

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.”
}

1 Like

if run this code instead:

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?

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

Hello, yes - the solution was found here:

1 Like

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