How to pass string output from triton python backend

trying this in the python backend
data = np.array([str(i).encode(“utf-8”) for i in string_data])
out_tensor_0 = pb_utils.Tensor(“OUTPUT0”,data)
inference_response = pb_utils.InferenceResponse(
output_tensors=[out_tensor_0])
output returning is None

@sivagurunathan.a ,

Can you check the following example: client/simple_grpc_string_infer_client.py at main · triton-inference-server/client · GitHub

@bgiddwani reference you have shared tried before and resulted as I specified above. we need some examples on the python backend side. here python_backend/examples at main · triton-inference-server/python_backend · GitHub both examples are having numpy array as output.

Hi @sivagurunathan.a ,

You can create a Json file or Dictionary in the python_backend side to pass the string output. [That means custom backend]. The same way I am doing in client side here:-
app.ipynb (7.6 KB)
labels.json (24.1 KB)

1 Like

@bgiddwani tried the string approach in the github server/qa/python_models at main · triton-inference-server/server · GitHub, it’s working perfectly. thank you!