提交 c3eaa149 编写于 作者: W wangjiawei04

fix for iPipe2

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