test_client.py 520 字节
Newer Older
G
guru4elephant 已提交
1
from paddle_serving_client import Client
G
guru4elephant 已提交
2 3 4 5 6 7 8 9
import sys

client = Client()
client.load_client_config(sys.argv[1])
client.connect(["127.0.0.1:9292"])

for line in sys.stdin:
    group = line.strip().split()
G
guru4elephant 已提交
10
    words = [int(x) for x in group[1:int(group[0]) + 1]]
G
guru4elephant 已提交
11 12
    label = [int(group[-1])]
    feed = {"words": words, "label": label}
G
guru4elephant 已提交
13
    fetch = ["cost", "acc", "prediction"]
G
guru4elephant 已提交
14
    fetch_map = client.predict(feed=feed, fetch=fetch)
G
guru4elephant 已提交
15 16
    print(fetch_map)
    #print("{} {}".format(fetch_map["prediction"][1], label[0]))
G
guru4elephant 已提交
17