提交 feb46a7d 编写于 作者: R root

fix imagenet res50

上级 6e643312
...@@ -47,8 +47,11 @@ def run_http(idx, batch_size): ...@@ -47,8 +47,11 @@ def run_http(idx, batch_size):
image_data1 = file.read() image_data1 = file.read()
image = cv2_to_base64(image_data1) image = cv2_to_base64(image_data1)
data = {"key": ["image"], "value": [image]} data = {"key": ["image"], "value": [image]}
for i in range(100): start_time = time.time()
while True:
r = requests.post(url=url, data=json.dumps(data)) r = requests.post(url=url, data=json.dumps(data))
if time.time() - start_time > 10:
break
end = time.time() end = time.time()
return [[end - start]] return [[end - start]]
...@@ -58,16 +61,18 @@ def multithread_http(thread, batch_size): ...@@ -58,16 +61,18 @@ def multithread_http(thread, batch_size):
def run_rpc(thread, batch_size): def run_rpc(thread, batch_size):
client = PipelineClient() client = PipelineClient()
client.connect(['127.0.0.1:18090']) client.connect(['127.0.0.1:18080'])
start = time.time() start = time.time()
test_img_dir = "imgs/" test_img_dir = "imgs/"
for img_file in os.listdir(test_img_dir): for img_file in os.listdir(test_img_dir):
with open(os.path.join(test_img_dir, img_file), 'rb') as file: with open(os.path.join(test_img_dir, img_file), 'rb') as file:
image_data = file.read() image_data = file.read()
image = cv2_to_base64(image_data) image = cv2_to_base64(image_data)
start_time = time.time()
for i in range(100): while True:
ret = client.predict(feed_dict={"image": image}, fetch=["res"]) ret = client.predict(feed_dict={"image": image}, fetch=["res"])
if time.time() - start_time > 10:
break
end = time.time() end = time.time()
return [[end - start]] return [[end - start]]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册