Soulduck
Soulduck

Reputation: 615

How can I send request using python to the tensorflow server (tensorflow-serving)?

I'm new tensorflow-serving.

i tried to send request(POST) to tensorflow server using python3,

but when i send reqeust, i got <400> , bad request.

but when i send curl on terminal, it's work.

curl -d '{"instances": [3]}' -X POST http://localhost:8501/v1/models/hello_world:predict

this is my python code.

import requests
import json

urls = 'http://localhost:8501/v1/models/chachacha:predict'
data = {"instances": 2858}
j_data = json.dumps(data)
r = requests.post(urls, json=j_data)
print(r)

error message :

<Response [400]>

Thank you for any advice!

Upvotes: 1

Views: 438

Answers (1)

Fasty
Fasty

Reputation: 804

try this

data = { "instances": [values]}
payld = json.dumps(data)
ret = requests.post(url, data=payld)

Upvotes: 2

Related Questions