Last active
October 1, 2022 20:05
-
-
Save zabir-nabil/1e4aa51d562413e89e4fdb83cde6e79a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python triton client | |
import numpy as np | |
import sys | |
import tritonclient.grpc as grpcclient | |
try: | |
keepalive_options = grpcclient.KeepAliveOptions( | |
keepalive_time_ms=2**31 - 1, | |
keepalive_timeout_ms=20000, | |
keepalive_permit_without_calls=False, | |
http2_max_pings_without_data=2 | |
) | |
triton_client = grpcclient.InferenceServerClient( | |
url='localhost:8001', | |
verbose=False, | |
keepalive_options=keepalive_options) | |
except Exception as e: | |
print("channel creation failed: " + str(e)) | |
sys.exit() | |
model_name = "ecapatdnn" | |
# Infer | |
inputs = [] | |
outputs = [] | |
inputs.append(grpcclient.InferInput('INPUT__0', [1, 48000], "FP32")) | |
# batch size = 1, signal length = 48000 | |
input0_data = np.random.randn(1, 48000).astype(np.float32) | |
# Initialize the data | |
inputs[0].set_data_from_numpy(input0_data) | |
outputs.append(grpcclient.InferRequestedOutput('OUTPUT__0')) | |
# Test with outputs | |
results = triton_client.infer(model_name=model_name, | |
inputs=inputs, | |
outputs=outputs, | |
headers={'test': '1'}) | |
# Get the output arrays from the results | |
output0_data = results.as_numpy('OUTPUT__0') | |
print(output0_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment