Inference via sagemaker endpoint

#12
by shum123 - opened

Hi! How do i call this for inference with an image via a sagemaker endpoint?

send request

predictor.predict({
"inputs": "My name is Clara and I am", "parameters":parameters
})
This works, but how do i include an image in the input?

I tried this:
image_path ='./images/powercord.jpg'
with open(image_path, "rb") as f:
image = base64.b64encode(f.read()).decode("utf-8")

payload = { "inputs" :{
"prompt": "detect powercord",
"image": image
}}

query_response = predictor.predict(data=payload)

But im getting this error - An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (422) from primary with message "Failed to deserialize the JSON body into the target type: inputs: invalid type: map, expected a string at line 1 column 11".

Sign up or log in to comment