-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcold_war_client.py
34 lines (22 loc) · 1.11 KB
/
cold_war_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding:utf-8 -*-
import json
import requests
import time
# docker run -p 8500:8500 -p 8501:8501 \
# --mount type=bind,source=/Users/zb/code/deeplearning/Text\ Matching/bert_sim/saved_model_0622,target=/models/serving_model \
# -e MODEL_NAME=serving_model -t tensorflow/serving
textmod = {}
textmod["inputs"] = {"input_left": [[1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
"input_right": [[1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
"keep_prob": 1.0}
textmod["signature_name"] = "predict_cls"
textmod["num"] = 2
header_dict = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko',"Content-Type": "application/json"}
url='http://localhost:8866/similarity'
#url = 'http://localhost:8501/v1/models/serving_model:predict'
start_time = time.time()
for i in range(1000):
r = requests.post(url, json=textmod, headers=header_dict, verify=False)
end_time = time.time()
print(r.text)
print("total cost time: {}".format((end_time-start_time)))