1
$\begingroup$

I have been succeed to deploy my model on tensorflow serving.

My model takes in a base64 string as input and predicts some output. I was able to test it using the following restApi

def http_request(img):
    image_as_txt = encode_image(img)
    payload = {
        "signature_name": "predict",
        "inputs":
            {
                "image": {"b64": image_as_txt}
            }
    }
    headers = {
        'Content-Type': "application/json"
    }

    response = requests.request("POST", 'http://10.10.10.2:8501/v1/models/my_model:predict", data=json.dumps(payload),
                            headers=headers)
    print(json.loads(response.text))

The above code is working fine till now

now I am trying to do the same using a gRPC client request for which I am using the below code

channel = grpc.insecure_channel('10.10.10.2:8500')

stub = prediction_service_pb2_grpc.PredictionServiceStub(channel)

request = predict_pb2.PredictRequest()
request.model_spec.name = 'my_model'
request.model_spec.signature_name = 'predict'

image_as_txt = //Some base64 image//
request.inputs['image'].CopyFrom(make_tensor_proto(image_as_txt),shape=())
res = result_future.result()
print(result_future.result())

but getting the following error

 [Unable to decode bytes as JPEG, PNG, GIF, or BMP]  [[{{node decode_image/cond_jpeg/cond_png/cond_gif/Assert_1/Assert}}]]","grpc_status":3}"

can anyone help me to send base64 images to my model

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.