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",
                "image": {"b64": image_as_txt}
    headers = {
        'Content-Type': "application/json"

    response = requests.request("POST", '", data=json.dumps(payload),

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('')

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//
res = 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


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.