Status 400 :Invalid json data when posting http request
YifengChen94 opened this issue · 1 comments
YifengChen94 commented
I have successfully deployed my model but I got some problems when trying to post http request. The shape of my model input tensor is (-1,-1-1,3). The Graph Signature information is listed below
The following code is used to post request
import cv2
import numpy as np
import json
import requests
img = cv2.imread('./Images/0001TP_008550.png')
img = cv2.resize(img,(352,288))
rows = img.shape[0]
cols = img.shape[1]
img = np.expand_dims(img,0)
dict_min = {"images":img.tolist()}
endpoint = "http://127.0.0.1:8500"
jsr=json.dumps(dict_min)
result = requests.post(endpoint, json=jsr)
print(result.text)
I know this is a problem with my data format, but how could I solve it? Thx a lot.
tobegit3hub commented
The OpenCV python image object would not be submitted as json data.
You can refer to our image client which will read the image file and parse to json string for inference. Please refer to https://github.com/tobegit3hub/simple_tensorflow_serving/blob/master/clients/python_client/image_client.py .