提交 c3eaa149 编写于 作者: W wangjiawei04

fix for iPipe2

上级 57d5ca2d
...@@ -34,7 +34,4 @@ for line in sys.stdin: ...@@ -34,7 +34,4 @@ for line in sys.stdin:
feed_dict[key] = np.array(feed_dict[key]).reshape((128, 1)) feed_dict[key] = np.array(feed_dict[key]).reshape((128, 1))
#print(feed_dict) #print(feed_dict)
result = client.predict(feed=feed_dict, fetch=fetch) result = client.predict(feed=feed_dict, fetch=fetch)
print(result)
print(result)
print(result)
print(result) print(result)
...@@ -20,7 +20,7 @@ import os ...@@ -20,7 +20,7 @@ import os
import time import time
import criteo_reader as criteo import criteo_reader as criteo
from paddle_serving_client.metric import auc from paddle_serving_client.metric import auc
import numpy as np
import sys import sys
py_version = sys.version_info[0] py_version = sys.version_info[0]
...@@ -49,7 +49,8 @@ for ei in range(1000): ...@@ -49,7 +49,8 @@ for ei in range(1000):
data = reader().__next__() data = reader().__next__()
feed_dict = {} feed_dict = {}
for i in range(1, 27): for i in range(1, 27):
feed_dict["sparse_{}".format(i - 1)] = data[0][i] feed_dict["sparse_{}".format(i - 1)] = np.array(data[0][i]).reshape(-1)
feed_dict["sparse_{}.lod".format(i - 1)] = [0, len(data[0][i])]
fetch_map = client.predict(feed=feed_dict, fetch=["prob"]) fetch_map = client.predict(feed=feed_dict, fetch=["prob"])
end = time.time() end = time.time()
print(end - start) print(end - start)
...@@ -36,6 +36,6 @@ fetch_map = client.predict( ...@@ -36,6 +36,6 @@ fetch_map = client.predict(
"im_info": np.array(list(im.shape[1:]) + [1.0]), "im_info": np.array(list(im.shape[1:]) + [1.0]),
"im_shape": np.array(list(im.shape[1:]) + [1.0]) "im_shape": np.array(list(im.shape[1:]) + [1.0])
}, },
fetch=["multiclass_nms"]) fetch=["multiclass_nms"], batch=False)
fetch_map["image"] = sys.argv[3] fetch_map["image"] = sys.argv[3]
postprocess(fetch_map) postprocess(fetch_map)
...@@ -28,10 +28,8 @@ test_reader = paddle.batch( ...@@ -28,10 +28,8 @@ test_reader = paddle.batch(
for data in test_reader(): for data in test_reader():
import numpy as np import numpy as np
new_data = np.zeros((2, 1, 13)).astype("float32") new_data = np.zeros((1, 1, 13)).astype("float32")
new_data[0] = data[0][0] new_data[0] = data[0][0]
new_data[1] = data[0][0]
print(new_data)
fetch_map = client.predict( fetch_map = client.predict(
feed={"x": new_data}, fetch=["price"], batch=True) feed={"x": new_data}, fetch=["price"], batch=True)
print("{} {}".format(fetch_map["price"][0], data[0][1][0])) print("{} {}".format(fetch_map["price"][0], data[0][1][0]))
......
...@@ -17,6 +17,7 @@ import os ...@@ -17,6 +17,7 @@ import os
import sys import sys
import time import time
import requests import requests
import numpy as np
from paddle_serving_app.reader import IMDBDataset from paddle_serving_app.reader import IMDBDataset
from paddle_serving_client import Client from paddle_serving_client import Client
from paddle_serving_client.utils import MultiThreadRunner from paddle_serving_client.utils import MultiThreadRunner
...@@ -47,11 +48,13 @@ def single_func(idx, resource): ...@@ -47,11 +48,13 @@ def single_func(idx, resource):
for i in range(1000): for i in range(1000):
if args.batch_size >= 1: if args.batch_size >= 1:
feed_batch = [] feed_batch = []
feed = {"words": [], "words.lod":[0]}
for bi in range(args.batch_size): for bi in range(args.batch_size):
word_ids, label = imdb_dataset.get_words_and_label(dataset[ word_ids, label = imdb_dataset.get_words_and_label(dataset[bi])
bi]) feed["words.lod"].append(feed["words.lod"][-1] + len(word_ids))
feed_batch.append({"words": word_ids}) feed["words"].extend(word_ids)
result = client.predict(feed=feed_batch, fetch=["prediction"]) feed["words"] = np.array(feed["words"]).reshape(len(feed["words"]), 1)
result = client.predict(feed=feed, fetch=["prediction"], batch=True)
if result is None: if result is None:
raise ("predict failed.") raise ("predict failed.")
else: else:
......
...@@ -10,5 +10,13 @@ op: ...@@ -10,5 +10,13 @@ op:
concurrency: 2 concurrency: 2
remote_service_conf: remote_service_conf:
client_type: brpc client_type: brpc
model_config: ocr_det_model model_config: imdb_bow_model
devices: "" devices: ""
rpc_port : 9393
cnn:
concurrency: 2
remote_service_conf:
client_type: brpc
model_config: imdb_cnn_model
devices: ""
rpc_port : 9292
...@@ -35,6 +35,6 @@ fetch_map = client.predict( ...@@ -35,6 +35,6 @@ fetch_map = client.predict(
"image": im, "image": im,
"im_size": np.array(list(im.shape[1:])), "im_size": np.array(list(im.shape[1:])),
}, },
fetch=["save_infer_model/scale_0.tmp_0"]) fetch=["save_infer_model/scale_0.tmp_0"], batch=False)
fetch_map["image"] = sys.argv[1] fetch_map["image"] = sys.argv[1]
postprocess(fetch_map) postprocess(fetch_map)
...@@ -835,8 +835,7 @@ class Op(object): ...@@ -835,8 +835,7 @@ class Op(object):
self.concurrency_idx = None self.concurrency_idx = None
# init client # init client
self.client = self.init_client(self._client_config, self.client = self.init_client(self._client_config,
self._server_endpoints, self._server_endpoints)
self._fetch_names)
# user defined # user defined
self.init_op() self.init_op()
self._succ_init_op = True self._succ_init_op = True
...@@ -845,7 +844,7 @@ class Op(object): ...@@ -845,7 +844,7 @@ class Op(object):
self.concurrency_idx = concurrency_idx self.concurrency_idx = concurrency_idx
# init client # init client
self.client = self.init_client( self.client = self.init_client(
self._client_config, self._server_endpoints, self._fetch_names) self._client_config, self._server_endpoints)
# user defined # user defined
self.init_op() self.init_op()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册