test_client.py 502 字节
Newer Older
G
guru4elephant 已提交
1
from paddle_serving.serving_client import Client
G
guru4elephant 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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()
    words = [int(x) for x in group[1:int(group[0])]]
    label = [int(group[-1])]
    feed = {"words": words, "label": label}
    fetch = ["acc", "cost", "prediction"]
    fetch_map = client.predict(feed=feed, fetch=fetch)
    print("{} {}".format(fetch_map["prediction"][1], label[0]))