-
How do I extract the desired result in the response from image = ...
inputs = [
tritonclient.InferInput("image", image.shape, "FP32"),
]
inputs[0].set_data_from_numpy(image.astype(np.float32))
model_name = "git"
url = "triton:8000" # HTTP
# url = "triton:8001" # gRPC
model_version = "1"
output_name = "generated_caption"
output = tritonclient.InferRequestedOutput(output_name)
with tritonclient.InferenceServerClient(url, verbose=False) as client:
response = client.infer(model_name, model_version=model_version, inputs=inputs, outputs=[output])
# How do I handle variable `response` depending on the protocol? I want to retrieve the `"generated_caption"` value Here's the model's config.pbtxt:
I'm using the Python backend, and in the inference_response = pb_utils.InferenceResponse(
output_tensors=[
pb_utils.Tensor(
"generated_caption",
np.array([output.encode("UTF-8")], dtype=np.bytes_),
)
]
) |
Beta Was this translation helpful? Give feedback.
Answered by
bacalfa
Dec 17, 2024
Replies: 1 comment
-
As I suspected, it shouldn't matter which protocol. I realized I can just do the following: generated_caption = response.as_numpy(output_name)[0].decode("UTF-8") Perfect! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bacalfa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As I suspected, it shouldn't matter which protocol. I realized I can just do the following:
Perfect!