test_client.py 498 字节
Newer Older
G
guru4elephant 已提交
1
from paddle_serving_client import Client
G
guru4elephant 已提交
2 3 4 5
import sys

client = Client()
client.load_client_config(sys.argv[1])
6
client.connect(["127.0.0.1:9393"])
G
guru4elephant 已提交
7 8 9

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 = ["acc", "cost", "prediction"]
G
guru4elephant 已提交
14
    fetch_map = client.predict(feed=feed, fetch=fetch)
G
guru4elephant 已提交
15
    print("{} {}".format(fetch_map["prediction"][1], label[0]))
G
guru4elephant 已提交
16