提交 a63a00a6 编写于 作者: B barrierye

add ndarray and list input support

上级 335e7219
......@@ -19,6 +19,7 @@ from paddle_serving_client import MultiLangClient, Client
from concurrent import futures
import logging
import func_timeout
from numpy import *
from .proto import pipeline_service_pb2
from .channel import ThreadChannel, ProcessChannel, ChannelDataEcode, ChannelData, ChannelDataType
......@@ -391,7 +392,12 @@ class RequestOp(Op):
def unpack_request_package(self, request):
dictdata = {}
for idx, key in enumerate(request.key):
dictdata[key] = request.value[idx]
data = request.value[idx]
try:
data = eval(data)
except Exception as e:
pass
dictdata[key] = data
return dictdata
......
......@@ -35,10 +35,16 @@ class PipelineClient(object):
def _pack_request_package(self, feed_dict):
req = pipeline_service_pb2.Request()
for key, value in feed_dict.items():
if not isinstance(value, str):
raise TypeError("only str type is supported.")
req.key.append(key)
req.value.append(value)
if isinstance(value, np.ndarray):
req.value.append(value.__repr__())
elif isinstance(value, str):
req.value.append(value)
elif isinstance(value, list):
req.value.append(np.array(value).__repr__())
else:
raise TypeError("only str and np.ndarray type is supported: {}".
format(type(value)))
return req
def _unpack_response_package(self, resp, fetch):
......@@ -50,7 +56,7 @@ class PipelineClient(object):
continue
data = resp.value[idx]
try:
data = eval(resp.value[idx])
data = eval(data)
except Exception as e:
pass
fetch_map[key] = data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册