未验证 提交 e420b8ca 编写于 作者: C chenjian 提交者: GitHub

fix coompatible pproblem for python3.10 and gradio (#1249)

上级 6ae08385
...@@ -12,8 +12,7 @@ packaging ...@@ -12,8 +12,7 @@ packaging
x2paddle >= 1.4.0 x2paddle >= 1.4.0
paddle2onnx >= 1.0.5 paddle2onnx >= 1.0.5
rarfile rarfile
gradio gradio == 3.11.0
tritonclient[all] tritonclient[all]
attrdict
psutil psutil
onnx >= 1.6.0 onnx >= 1.6.0
...@@ -18,13 +18,6 @@ import re ...@@ -18,13 +18,6 @@ import re
import numpy as np import numpy as np
import requests import requests
import tritonclient.http as httpclient import tritonclient.http as httpclient
from attrdict import AttrDict
def convert_http_metadata_config(metadata):
metadata = AttrDict(metadata)
return metadata
def prepare_request(inputs_meta, inputs_data, outputs_meta): def prepare_request(inputs_meta, inputs_data, outputs_meta):
...@@ -58,7 +51,7 @@ def prepare_request(inputs_meta, inputs_data, outputs_meta): ...@@ -58,7 +51,7 @@ def prepare_request(inputs_meta, inputs_data, outputs_meta):
inputs.append(infer_input) inputs.append(infer_input)
outputs = [] outputs = []
for output_dict in outputs_meta: for output_dict in outputs_meta:
infer_output = httpclient.InferRequestedOutput(output_dict.name) infer_output = httpclient.InferRequestedOutput(output_dict['name'])
outputs.append(infer_output) outputs.append(infer_output)
return inputs, outputs return inputs, outputs
...@@ -321,8 +314,8 @@ class HttpClientManager: ...@@ -321,8 +314,8 @@ class HttpClientManager:
results = {} results = {}
for output in output_metadata: for output in output_metadata:
result = response.as_numpy(output.name) # datatype: numpy result = response.as_numpy(output['name']) # datatype: numpy
if output.datatype == 'BYTES': # datatype: bytes if output['datatype'] == 'BYTES': # datatype: bytes
try: try:
value = result value = result
if len(result.shape) == 1: if len(result.shape) == 1:
...@@ -336,7 +329,7 @@ class HttpClientManager: ...@@ -336,7 +329,7 @@ class HttpClientManager:
pass pass
else: else:
result = result[0] result = result[0]
results[output.name] = result results[output['name']] = result
return results return results
def raw_infer(self, server_url, model_name, model_version, raw_input): def raw_infer(self, server_url, model_name, model_version, raw_input):
...@@ -353,8 +346,6 @@ class HttpClientManager: ...@@ -353,8 +346,6 @@ class HttpClientManager:
except Exception as e: except Exception as e:
raise RuntimeError("Failed to retrieve the metadata: " + str(e)) raise RuntimeError("Failed to retrieve the metadata: " + str(e))
model_metadata = convert_http_metadata_config(model_metadata) input_metadata = model_metadata['inputs']
output_metadata = model_metadata['outputs']
input_metadata = model_metadata.inputs
output_metadata = model_metadata.outputs
return input_metadata, output_metadata return input_metadata, output_metadata
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册